Skip to content

Commit 5214caa

Browse files
committed
[CODEC-125] Implement a Beider-Morse phonetic matching codec. No need to create 7000+ of the same object on startup and keep it around.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1154949 13f79535-47bb-0310-9956-ffa450edef68
1 parent b263fbf commit 5214caa

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

  • src/java/org/apache/commons/codec/language/bm

src/java/org/apache/commons/codec/language/bm/Rule.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ public boolean find() {
229229

230230
}
231231

232+
private static class AllStringsRMatcher implements RPattern {
233+
234+
private static AllStringsRMatcher INSTANCE = new AllStringsRMatcher();
235+
236+
public RMatcher matcher(CharSequence input) {
237+
return TrueRMatcher.INSTANCE;
238+
}
239+
240+
}
241+
232242
/**
233243
* A minimal wrapper around the functionality of Pattern that we use, to allow for alternate implementations.
234244
*/
@@ -511,11 +521,7 @@ public boolean find() {
511521
}
512522
} else if ((startsWith || endsWith) && content.length() == 0) {
513523
// matches every string
514-
return new RPattern() {
515-
public RMatcher matcher(CharSequence input) {
516-
return TrueRMatcher.INSTANCE;
517-
}
518-
};
524+
return AllStringsRMatcher.INSTANCE;
519525
} else if (startsWith) {
520526
// matches from start
521527
return new RPattern() {

0 commit comments

Comments
 (0)