From b86e8e90975ddfa57432692846e49ab804ab1376 Mon Sep 17 00:00:00 2001 From: Michael Busch Date: Sat, 23 Feb 2008 02:35:14 +0000 Subject: [PATCH] LUCENE-1185: Avoid checking if the TermBuffer 'scratch' in SegmentTermEnum is null for every call of scanTo(). git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@630377 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 ++++ src/java/org/apache/lucene/index/SegmentTermEnum.java | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index f9fd2e45ba6..e43f898aa76 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -113,6 +113,10 @@ Optimizations 2. LUCENE-1120: Speed up merging of term vectors by bulk-copying the raw bytes for each contiguous range of non-deleted documents. (Mike McCandless) + + 3. LUCENE-1185: Avoid checking if the TermBuffer 'scratch' in + SegmentTermEnum is null for every call of scanTo(). + (Christian Kohlschuetter via Michael Busch) Documentation diff --git a/src/java/org/apache/lucene/index/SegmentTermEnum.java b/src/java/org/apache/lucene/index/SegmentTermEnum.java index 78f6f3a2b7e..46e1a7943ec 100644 --- a/src/java/org/apache/lucene/index/SegmentTermEnum.java +++ b/src/java/org/apache/lucene/index/SegmentTermEnum.java @@ -28,7 +28,7 @@ final class SegmentTermEnum extends TermEnum implements Cloneable { private TermBuffer termBuffer = new TermBuffer(); private TermBuffer prevBuffer = new TermBuffer(); - private TermBuffer scratch; // used for scanning + private TermBuffer scanBuffer = new TermBuffer(); // used for scanning private TermInfo termInfo = new TermInfo(); @@ -97,7 +97,7 @@ final class SegmentTermEnum extends TermEnum implements Cloneable { clone.termBuffer = (TermBuffer)termBuffer.clone(); clone.prevBuffer = (TermBuffer)prevBuffer.clone(); - clone.scratch = null; + clone.scanBuffer = new TermBuffer(); return clone; } @@ -148,10 +148,8 @@ final class SegmentTermEnum extends TermEnum implements Cloneable { /** Optimized scan, without allocating new terms. */ final void scanTo(Term term) throws IOException { - if (scratch == null) - scratch = new TermBuffer(); - scratch.set(term); - while (scratch.compareTo(termBuffer) > 0 && next()) {} + scanBuffer.set(term); + while (scanBuffer.compareTo(termBuffer) > 0 && next()) {} } /** Returns the current Term in the enumeration.