optimize array list creation with exact size

This commit is contained in:
kimchy 2011-03-28 21:50:39 +02:00
parent 49f79f54d2
commit 53935f078a
3 changed files with 3 additions and 3 deletions

View File

@ -245,7 +245,7 @@ public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet {
} else {
Object[] values = map.internalValues();
Arrays.sort(values, (Comparator) comparatorType.comparator());
List<DoubleEntry> ordered = new ArrayList<DoubleEntry>();
List<DoubleEntry> ordered = new ArrayList<DoubleEntry>(map.size());
for (int i = 0; i < requiredSize; i++) {
DoubleEntry value = (DoubleEntry) values[i];
if (value == null) {

View File

@ -245,7 +245,7 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet {
} else {
Object[] values = map.internalValues();
Arrays.sort(values, (Comparator) comparatorType.comparator());
List<LongEntry> ordered = new ArrayList<LongEntry>();
List<LongEntry> ordered = new ArrayList<LongEntry>(map.size());
for (int i = 0; i < requiredSize; i++) {
LongEntry value = (LongEntry) values[i];
if (value == null) {

View File

@ -244,7 +244,7 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet {
} else {
Object[] values = map.internalValues();
Arrays.sort(values, (Comparator) comparatorType.comparator());
List<StringEntry> ordered = new ArrayList<StringEntry>();
List<StringEntry> ordered = new ArrayList<StringEntry>(map.size());
for (int i = 0; i < requiredSize; i++) {
StringEntry value = (StringEntry) values[i];
if (value == null) {