From 53935f078a73c828be301a2c850e139ba9c2a8c9 Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 28 Mar 2011 21:50:39 +0200 Subject: [PATCH] optimize array list creation with exact size --- .../facet/termsstats/doubles/InternalTermsStatsDoubleFacet.java | 2 +- .../facet/termsstats/longs/InternalTermsStatsLongFacet.java | 2 +- .../facet/termsstats/strings/InternalTermsStatsStringFacet.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/InternalTermsStatsDoubleFacet.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/InternalTermsStatsDoubleFacet.java index adc856dc736..b43264a450d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/InternalTermsStatsDoubleFacet.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/InternalTermsStatsDoubleFacet.java @@ -245,7 +245,7 @@ public class InternalTermsStatsDoubleFacet extends InternalTermsStatsFacet { } else { Object[] values = map.internalValues(); Arrays.sort(values, (Comparator) comparatorType.comparator()); - List ordered = new ArrayList(); + List ordered = new ArrayList(map.size()); for (int i = 0; i < requiredSize; i++) { DoubleEntry value = (DoubleEntry) values[i]; if (value == null) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/longs/InternalTermsStatsLongFacet.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/longs/InternalTermsStatsLongFacet.java index ae270b841e0..16bd797ca6f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/longs/InternalTermsStatsLongFacet.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/longs/InternalTermsStatsLongFacet.java @@ -245,7 +245,7 @@ public class InternalTermsStatsLongFacet extends InternalTermsStatsFacet { } else { Object[] values = map.internalValues(); Arrays.sort(values, (Comparator) comparatorType.comparator()); - List ordered = new ArrayList(); + List ordered = new ArrayList(map.size()); for (int i = 0; i < requiredSize; i++) { LongEntry value = (LongEntry) values[i]; if (value == null) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/strings/InternalTermsStatsStringFacet.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/strings/InternalTermsStatsStringFacet.java index e045ca86781..56905e3a628 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/strings/InternalTermsStatsStringFacet.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/termsstats/strings/InternalTermsStatsStringFacet.java @@ -244,7 +244,7 @@ public class InternalTermsStatsStringFacet extends InternalTermsStatsFacet { } else { Object[] values = map.internalValues(); Arrays.sort(values, (Comparator) comparatorType.comparator()); - List ordered = new ArrayList(); + List ordered = new ArrayList(map.size()); for (int i = 0; i < requiredSize; i++) { StringEntry value = (StringEntry) values[i]; if (value == null) {