diff --git a/CHANGES.txt b/CHANGES.txt index 8479e7d88ee..8cc78cfcee5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -221,6 +221,9 @@ Optimizations queries involving term positions, including phrase queries. (Michael Busch via Yonik Seeley) + 12. LUCENE-714: Replaced 2 cases of manual for-loop array copying + with calls to System.arraycopy instead, in DocumentWriter.java. + (Nicolas Lalevee via Mike McCandless) Test Cases 1. Added TestTermScorer.java (Grant Ingersoll) diff --git a/src/java/org/apache/lucene/index/DocumentWriter.java b/src/java/org/apache/lucene/index/DocumentWriter.java index ff448bd6b09..a704e92895e 100644 --- a/src/java/org/apache/lucene/index/DocumentWriter.java +++ b/src/java/org/apache/lucene/index/DocumentWriter.java @@ -206,8 +206,7 @@ final class DocumentWriter { if (ti.positions.length == freq) { // positions array is full int[] newPositions = new int[freq * 2]; // double size int[] positions = ti.positions; - for (int i = 0; i < freq; i++) // copy old positions to new - newPositions[i] = positions[i]; + System.arraycopy(positions, 0, newPositions, 0, freq); ti.positions = newPositions; } ti.positions[freq] = position; // add new position @@ -216,10 +215,7 @@ final class DocumentWriter { if (ti.offsets.length == freq){ TermVectorOffsetInfo [] newOffsets = new TermVectorOffsetInfo[freq*2]; TermVectorOffsetInfo [] offsets = ti.offsets; - for (int i = 0; i < freq; i++) - { - newOffsets[i] = offsets[i]; - } + System.arraycopy(offsets, 0, newOffsets, 0, freq); ti.offsets = newOffsets; } ti.offsets[freq] = offset;