From 2db4c909ca10c0d7edd9999a0c94622fa1369833 Mon Sep 17 00:00:00 2001 From: kkewwei Date: Mon, 6 Jan 2020 16:19:08 +0800 Subject: [PATCH] LUCENE-9096:Simplify CompressingTermVectorsWriter#flushOffsets. (#1125) --- .../compressing/CompressingTermVectorsWriter.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsWriter.java index 46ac1283977..2509b9a33dc 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsWriter.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsWriter.java @@ -564,17 +564,9 @@ public final class CompressingTermVectorsWriter extends TermVectorsWriter { final int fieldNumOff = Arrays.binarySearch(fieldNums, fd.fieldNum); int pos = 0; for (int i = 0; i < fd.numTerms; ++i) { - int previousPos = 0; - int previousOff = 0; - for (int j = 0; j < fd.freqs[i]; ++j) { - final int position = positionsBuf[fd.posStart + pos]; - final int startOffset = startOffsetsBuf[fd.offStart + pos]; - sumPos[fieldNumOff] += position - previousPos; - sumOffsets[fieldNumOff] += startOffset - previousOff; - previousPos = position; - previousOff = startOffset; - ++pos; - } + sumPos[fieldNumOff] += positionsBuf[fd.posStart + fd.freqs[i]-1 + pos]; + sumOffsets[fieldNumOff] += startOffsetsBuf[fd.offStart + fd.freqs[i]-1 + pos]; + pos += fd.freqs[i]; } assert pos == fd.totalPositions; }