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:
Uwe Schindler 2009-08-24 14:03:51 +00:00
parent 5cd31d4683
commit eeb96239db
1 changed files with 4 additions and 8 deletions

View File

@ -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);