lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r917161 - in /lucene/java/trunk/contrib: CHANGES.txt analyzers/common/src/java/org/tartarus/snowball/Among.java analyzers/common/src/java/org/tartarus/snowball/SnowballProgram.java
Date Sun, 28 Feb 2010 10:41:28 GMT
Author: rmuir
Date: Sun Feb 28 10:41:28 2010
New Revision: 917161

URL: http://svn.apache.org/viewvc?rev=917161&view=rev
Log:
LUCENE-2288: remove more unnecessary snowball object creation

Modified:
    lucene/java/trunk/contrib/CHANGES.txt
    lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/Among.java
    lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/SnowballProgram.java

Modified: lucene/java/trunk/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/CHANGES.txt?rev=917161&r1=917160&r2=917161&view=diff
==============================================================================
--- lucene/java/trunk/contrib/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/CHANGES.txt Sun Feb 28 10:41:28 2010
@@ -121,6 +121,10 @@
    take advantage of this for faster performance.
    (Steven Rowe, Uwe Schindler, Robert Muir)
 
+ * LUCENE-2194, LUCENE-2201, LUCENE-2288: Snowball stemmers in contrib/analyzers
+   have been optimized to work on char[] and remove unnecessary object creation.
+   (Shai Erera, Robert Muir)
+
 Test Cases
 
  * LUCENE-2115: Cutover contrib tests to use Java5 generics.  (Kay Kay

Modified: lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/Among.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/Among.java?rev=917161&r1=917160&r2=917161&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/Among.java (original)
+++ lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/Among.java Sun
Feb 28 10:41:28 2010
@@ -34,6 +34,7 @@
 import java.lang.reflect.Method;
 
 public class Among {
+    private static final Class<?>[] EMPTY_PARAMS = new Class[0];
     public Among (String s, int substring_i, int result,
 		  String methodname, SnowballProgram methodobject) {
         this.s_size = s.length();
@@ -46,7 +47,7 @@
 	} else {
 	    try {
 		this.method = methodobject.getClass().
-		getDeclaredMethod(methodname, new Class[0]);
+		getDeclaredMethod(methodname, EMPTY_PARAMS);
 	    } catch (NoSuchMethodException e) {
 		throw new RuntimeException(e);
 	    }

Modified: lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/SnowballProgram.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/SnowballProgram.java?rev=917161&r1=917160&r2=917161&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/SnowballProgram.java
(original)
+++ lucene/java/trunk/contrib/analyzers/common/src/java/org/tartarus/snowball/SnowballProgram.java
Sun Feb 28 10:41:28 2010
@@ -44,8 +44,11 @@
  * refactored StringBuffers to StringBuilder
  * uses char[] as buffer instead of StringBuffer/StringBuilder
  * eq_s,eq_s_b,insert,replace_s take CharSequence like eq_v and eq_v_b
+ * reflection calls (Lovins, etc) use EMPTY_ARGS/EMPTY_PARAMS
  */
 public abstract class SnowballProgram {
+    private static final Object[] EMPTY_ARGS = new Object[0];
+
     protected SnowballProgram()
     {
 	current = new char[8];
@@ -337,8 +340,7 @@
 		if (w.method == null) return w.result;
 		boolean res;
 		try {
-		    Object resobj = w.method.invoke(w.methodobject,
-						    new Object[0]);
+		    Object resobj = w.method.invoke(w.methodobject, EMPTY_ARGS);
 		    res = resobj.toString().equals("true");
 		} catch (InvocationTargetException e) {
 		    res = false;
@@ -406,8 +408,7 @@
 
 		boolean res;
 		try {
-		    Object resobj = w.method.invoke(w.methodobject,
-						    new Object[0]);
+		    Object resobj = w.method.invoke(w.methodobject, EMPTY_ARGS);
 		    res = resobj.toString().equals("true");
 		} catch (InvocationTargetException e) {
 		    res = false;



Mime
View raw message