commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1154949 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java
Date Mon, 08 Aug 2011 13:06:51 GMT
Author: ggregory
Date: Mon Aug  8 13:06:51 2011
New Revision: 1154949

URL: http://svn.apache.org/viewvc?rev=1154949&view=rev
Log:
[CODEC-125] Implement a Beider-Morse phonetic matching codec. No need to create 7000+ of the
same object on startup and keep it around.

Modified:
    commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java

Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java?rev=1154949&r1=1154948&r2=1154949&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java (original)
+++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Rule.java Mon
Aug  8 13:06:51 2011
@@ -229,6 +229,16 @@ public class Rule {
 
     }
 
+    private static class AllStringsRMatcher implements RPattern {
+
+        private static AllStringsRMatcher INSTANCE = new AllStringsRMatcher();
+
+        public RMatcher matcher(CharSequence input) {
+            return TrueRMatcher.INSTANCE;
+        }
+
+    }
+
     /**
      * A minimal wrapper around the functionality of Pattern that we use, to allow for alternate
implementations.
      */
@@ -511,11 +521,7 @@ public class Rule {
                 }
             } else if ((startsWith || endsWith) && content.length() == 0) {
                 // matches every string
-                return new RPattern() {
-                    public RMatcher matcher(CharSequence input) {
-                        return TrueRMatcher.INSTANCE;
-                    }
-                };
+                return AllStringsRMatcher.INSTANCE;
             } else if (startsWith) {
                 // matches from start
                 return new RPattern() {



Mime
View raw message