LUCENE-152: minor optimization to avoid some char[]/String creation

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1134328 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-06-10 14:00:32 +00:00
parent 6f8344a2f7
commit eca56e0564
2 changed files with 5 additions and 2 deletions

View File

@ -55,8 +55,7 @@ public final class KStemFilter extends TokenFilter {
char[] term = termAttribute.buffer();
int len = termAttribute.length();
if ((!keywordAtt.isKeyword()) && stemmer.stem(term, len)) {
char[] chars = stemmer.asString().toCharArray();
termAttribute.copyBuffer(chars, 0, chars.length);
termAttribute.setEmpty().append(stemmer.asCharSequence());
}
return true;

View File

@ -1373,6 +1373,10 @@ public class KStemmer {
return word.toString();
}
CharSequence asCharSequence() {
return result != null ? result : word;
}
String getString() {
return result;
}