From 4ef2d43d589da5cd7c2b6bd939ac05b1031a6002 Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Fri, 6 Nov 2015 11:16:21 +0000 Subject: [PATCH] LUCENE-6885: StandardDirectoryReader (initialCapacity) tweaks git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1712939 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ .../java/org/apache/lucene/index/StandardDirectoryReader.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 144a7a18403..5f69675962e 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -183,6 +183,9 @@ Optimizations * LUCENE-6878: Speed up TopDocs.merge. (Daniel Jelinski via Adrien Grand) +* LUCENE-6885: StandardDirectoryReader (initialCapacity) tweaks + (Christine Poerschke) + Bug Fixes * LUCENE-6817: ComplexPhraseQueryParser.ComplexPhraseQuery does not display diff --git a/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java b/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java index 373dad3f227..8d51532aa22 100644 --- a/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java +++ b/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java @@ -80,7 +80,7 @@ final class StandardDirectoryReader extends DirectoryReader { // no need to process segments in reverse order final int numSegments = infos.size(); - List readers = new ArrayList<>(); + final List readers = new ArrayList<>(numSegments); final Directory dir = writer.getDirectory(); final SegmentInfos segmentInfos = infos.clone(); @@ -136,7 +136,7 @@ final class StandardDirectoryReader extends DirectoryReader { // we put the old SegmentReaders in a map, that allows us // to lookup a reader using its segment name - final Map segmentReaders = new HashMap<>(); + final Map segmentReaders = (oldReaders == null ? Collections.emptyMap() : new HashMap<>(oldReaders.size())); if (oldReaders != null) { // create a Map SegmentName->SegmentReader