optimize array list creation with exact size
This commit is contained in:
parent
49f79f54d2
commit
53935f078a
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue