Index: contrib/analyzers/common/src/java/org/apache/lucene/analysis/payloads/DelimitedPayloadTokenFilter.java =================================================================== --- contrib/analyzers/common/src/java/org/apache/lucene/analysis/payloads/DelimitedPayloadTokenFilter.java (revision 890407) +++ contrib/analyzers/common/src/java/org/apache/lucene/analysis/payloads/DelimitedPayloadTokenFilter.java (working copy) @@ -61,26 +61,19 @@ @Override public boolean incrementToken() throws IOException { - boolean result = false; if (input.incrementToken()) { final char[] buffer = termAtt.termBuffer(); final int length = termAtt.termLength(); - //look for the delimiter - boolean seen = false; for (int i = 0; i < length; i++) { if (buffer[i] == delimiter) { - termAtt.setTermBuffer(buffer, 0, i); + termAtt.setTermLength(i); // simply set a new length payAtt.setPayload(encoder.encode(buffer, i + 1, (length - (i + 1)))); - seen = true; - break;//at this point, we know the whole piece, so we can exit. If we don't see the delimiter, then the termAtt is the same + return true; } } - if (seen == false) { - //no delimiter - payAtt.setPayload(null); - } - result = true; - } - return result; + // we have not seen the delimiter + payAtt.setPayload(null); + return true; + } else return false; } } Index: contrib/CHANGES.txt =================================================================== --- contrib/CHANGES.txt (revision 890407) +++ contrib/CHANGES.txt (working copy) @@ -65,6 +65,12 @@ into core, and moved the ICU-based collation support into contrib/icu. (Robert Muir) +Optimizations + + * LUCENE-2157: DelimitedPayloadTokenFilter no longer copies the buffer + over itsself. Instead it sets only the length. This patch also optimizes + the logic of the filter. (Uwe Schindler) + Test Cases * LUCENE-2115: Cutover contrib tests to use Java5 generics. (Kay Kay