This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d9a85de Remove redundant checks for whitespace in 
DaitchMokotoffSoundex.soundex(String, boolean)
0d9a85de is described below

commit 0d9a85de587f799791b7cf2a5fbd6a97d8d90251
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon May 19 10:48:25 2025 -0400

    Remove redundant checks for whitespace in
    DaitchMokotoffSoundex.soundex(String, boolean)
    
    - Whitespace are already removed in cleanup() before we get to the
    additional check
    - Remove extra vertical whitespace
---
 src/changes/changes.xml                                   |  1 +
 .../commons/codec/language/DaitchMokotoffSoundex.java     | 15 ---------------
 2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index eea6bb2a..37bdc598 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -53,6 +53,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile 
regular expressions in Lang.loadFromResource(String, Languages).</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile 
regular expressions in PhoneticEngine.encode(String, LanguageSet).</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile 
regular expressions in 
org.apache.commons.codec.language.bm.Rule.parse*(*).</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Remove redundant 
checks for whitespace in DaitchMokotoffSoundex.soundex(String, 
boolean).</action>
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
HmacUtils.hmac(Path).</action>      
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
HmacUtils.hmacHex(Path).</action>      
diff --git 
a/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java 
b/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
index b4f4b030..f0ffdf2a 100644
--- a/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
+++ b/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
@@ -464,30 +464,19 @@ public class DaitchMokotoffSoundex implements 
StringEncoder {
         if (source == null) {
             return null;
         }
-
         final String input = cleanup(source);
-
         final Set<Branch> currentBranches = new LinkedHashSet<>();
         currentBranches.add(new Branch());
-
         char lastChar = NUL;
         for (int index = 0; index < input.length(); index++) {
             final char ch = input.charAt(index);
-
-            // ignore whitespace inside a name
-            if (Character.isWhitespace(ch)) {
-                continue;
-            }
-
             final String inputContext = input.substring(index);
             final List<Rule> rules = RULES.get(ch);
             if (rules == null) {
                 continue;
             }
-
             // use an EMPTY_LIST to avoid false positive warnings wrt 
potential null pointer access
             final List<Branch> nextBranches = branching ? new ArrayList<>() : 
Collections.emptyList();
-
             for (final Rule rule : rules) {
                 if (rule.matches(inputContext)) {
                     if (branching) {
@@ -512,7 +501,6 @@ public class DaitchMokotoffSoundex implements StringEncoder 
{
                             nextBranches.add(nextBranch);
                         }
                     }
-
                     if (branching) {
                         currentBranches.clear();
                         currentBranches.addAll(nextBranches);
@@ -521,17 +509,14 @@ public class DaitchMokotoffSoundex implements 
StringEncoder {
                     break;
                 }
             }
-
             lastChar = ch;
         }
-
         final String[] result = new String[currentBranches.size()];
         int index = 0;
         for (final Branch branch : currentBranches) {
             branch.finish();
             result[index++] = branch.toString();
         }
-
         return result;
     }
 }

Reply via email to