mirror of https://github.com/apache/lucene.git
Sorry for the last commit, this is the better solution. As the offset attribute was normally already added before in the indexing process, the addAttribute is at no cost. And the additional if-clause is prevented (I missed a second one in the previous commit). Now only payloads are conditional to attribute existence.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@807223 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5cd31d4683
commit
eeb96239db
|
@ -195,8 +195,8 @@ final class TermVectorsTermsWriterPerField extends TermsHashConsumerPerField {
|
|||
}
|
||||
|
||||
void start(Fieldable f) {
|
||||
if (doVectorOffsets && fieldState.attributeSource.hasAttribute(OffsetAttribute.class)) {
|
||||
offsetAttribute = (OffsetAttribute) fieldState.attributeSource.getAttribute(OffsetAttribute.class);
|
||||
if (doVectorOffsets) {
|
||||
offsetAttribute = (OffsetAttribute) fieldState.attributeSource.addAttribute(OffsetAttribute.class);
|
||||
} else {
|
||||
offsetAttribute = null;
|
||||
}
|
||||
|
@ -211,12 +211,8 @@ final class TermVectorsTermsWriterPerField extends TermsHashConsumerPerField {
|
|||
p.freq = 1;
|
||||
|
||||
if (doVectorOffsets) {
|
||||
int startOffset = fieldState.offset;
|
||||
int endOffset = fieldState.offset;
|
||||
if (offsetAttribute != null) {
|
||||
startOffset += offsetAttribute.startOffset();
|
||||
endOffset += offsetAttribute.endOffset();
|
||||
}
|
||||
int startOffset = fieldState.offset + offsetAttribute.startOffset();;
|
||||
int endOffset = fieldState.offset + offsetAttribute.endOffset();
|
||||
|
||||
termsHashPerField.writeVInt(1, startOffset);
|
||||
termsHashPerField.writeVInt(1, endOffset - startOffset);
|
||||
|
|
Loading…
Reference in New Issue