From fa211e79d6819c82086357ba030de4c460338e5e Mon Sep 17 00:00:00 2001 From: Mark Harwood Date: Thu, 30 Jun 2005 20:57:18 +0000 Subject: [PATCH] added createTerm method to create Terms without incurring fieldName.intern() overhead git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@208682 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/index/Term.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/java/org/apache/lucene/index/Term.java b/src/java/org/apache/lucene/index/Term.java index f1d5bad14c4..afe6b821281 100644 --- a/src/java/org/apache/lucene/index/Term.java +++ b/src/java/org/apache/lucene/index/Term.java @@ -45,6 +45,17 @@ public final class Term implements Comparable, java.io.Serializable { text of the word. In the case of dates and other types, this is an encoding of the object as a string. */ public final String text() { return text; } + + /** + * Optimized construction of new Terms by reusing same field as this Term + * - avoids field.intern() overhead + * @param text The text of the new term (field is implicitly same as this Term instance) + * @return A new Term + */ + public Term createTerm(String text) + { + return new Term(field,text,false); + } /** Compares two terms, returning true iff they have the same field and text. */