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 {
|
} else {
|
||||||
Object[] values = map.internalValues();
|
Object[] values = map.internalValues();
|
||||||
Arrays.sort(values, (Comparator) comparatorType.comparator());
|
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++) {
|
for (int i = 0; i < requiredSize; i++) {
|
||||||
DoubleEntry value = (DoubleEntry) values[i];
|
DoubleEntry value = (DoubleEntry) values[i];
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
|
@ -245,7 +245,7 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet {
|
||||||
} else {
|
} else {
|
||||||
Object[] values = map.internalValues();
|
Object[] values = map.internalValues();
|
||||||
Arrays.sort(values, (Comparator) comparatorType.comparator());
|
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++) {
|
for (int i = 0; i < requiredSize; i++) {
|
||||||
LongEntry value = (LongEntry) values[i];
|
LongEntry value = (LongEntry) values[i];
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
|
@ -244,7 +244,7 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet {
|
||||||
} else {
|
} else {
|
||||||
Object[] values = map.internalValues();
|
Object[] values = map.internalValues();
|
||||||
Arrays.sort(values, (Comparator) comparatorType.comparator());
|
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++) {
|
for (int i = 0; i < requiredSize; i++) {
|
||||||
StringEntry value = (StringEntry) values[i];
|
StringEntry value = (StringEntry) values[i];
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
Loading…
Reference in New Issue