Index: contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java =================================================================== --- contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java (revision 801515) +++ contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java (working copy) @@ -22,6 +22,7 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.StopFilter; +import org.apache.lucene.util.StringHelper; import java.io.IOException; import java.io.Reader; @@ -137,7 +138,7 @@ */ public int addStopWords(IndexReader reader, String fieldName, int maxDocFreq) throws IOException { HashSet stopWords = new HashSet(); - String internedFieldName = fieldName.intern(); + String internedFieldName = StringHelper.intern(fieldName); TermEnum te = reader.terms(new Term(fieldName)); Term term = te.term(); while (term != null) { Index: contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java =================================================================== --- contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java (revision 801515) +++ contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java (working copy) @@ -323,24 +323,6 @@ * @see Field#setBoost(float) */ public void addField(String fieldName, TokenStream stream, float boost) { - /* - * Note that this method signature avoids having a user call new - * o.a.l.d.Field(...) which would be much too expensive due to the - * String.intern() usage of that class. - * - * More often than not, String.intern() leads to serious performance - * degradations rather than improvements! If you're curious why, check - * out the JDK's native code, see how it oscillates multiple times back - * and forth between Java code and native code on each intern() call, - * only to end up using a plain vanilla java.util.HashMap on the Java - * heap for it's interned strings! String.equals() has a small cost - * compared to String.intern(), trust me. Application level interning - * (e.g. a HashMap per Directory/Index) typically leads to better - * solutions than frequent hidden low-level calls to String.intern(). - * - * Perhaps with some luck, Lucene's Field.java (and Term.java) and - * cousins could be fixed to not use String.intern(). Sigh :-( - */ try { if (fieldName == null) throw new IllegalArgumentException("fieldName must not be null");