We are providing a bad hint to HashSet, as we are not taking
into consideration its load factor. Use utility methods from Guava
to get a properly-sized set.
JIRA: CONTROLLER-1898
Change-Id: I568be3040b924a8ed77aa0224ab45673104c4664
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
+import com.google.common.collect.Sets;
import java.io.DataInput;
import java.io.IOException;
import java.io.StringReader;
import java.io.DataInput;
import java.io.IOException;
import java.io.StringReader;
private Set<QName> readQNameSet() throws IOException {
// Read the children count
private Set<QName> readQNameSet() throws IOException {
// Read the children count
- int count = input.readInt();
- Set<QName> children = new HashSet<>(count);
+ final int count = input.readInt();
+ final Set<QName> children = Sets.newHashSetWithExpectedSize(count);
for (int i = 0; i < count; i++) {
children.add(readQName());
}
for (int i = 0; i < count; i++) {
children.add(readQName());
}