Skip to content

Commit 0d9a85d

Browse files
committed
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
1 parent 4357dc9 commit 0d9a85d

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The <action> type attribute can be add,update,fix,remove.
5353
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expressions in Lang.loadFromResource(String, Languages).</action>
5454
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expressions in PhoneticEngine.encode(String, LanguageSet).</action>
5555
<action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expressions in org.apache.commons.codec.language.bm.Rule.parse*(*).</action>
56+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Remove redundant checks for whitespace in DaitchMokotoffSoundex.soundex(String, boolean).</action>
5657
<!-- ADD -->
5758
<action type="add" dev="ggregory" due-to="Gary Gregory">Add HmacUtils.hmac(Path).</action>
5859
<action type="add" dev="ggregory" due-to="Gary Gregory">Add HmacUtils.hmacHex(Path).</action>

src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -464,30 +464,19 @@ private String[] soundex(final String source, final boolean branching) {
464464
if (source == null) {
465465
return null;
466466
}
467-
468467
final String input = cleanup(source);
469-
470468
final Set<Branch> currentBranches = new LinkedHashSet<>();
471469
currentBranches.add(new Branch());
472-
473470
char lastChar = NUL;
474471
for (int index = 0; index < input.length(); index++) {
475472
final char ch = input.charAt(index);
476-
477-
// ignore whitespace inside a name
478-
if (Character.isWhitespace(ch)) {
479-
continue;
480-
}
481-
482473
final String inputContext = input.substring(index);
483474
final List<Rule> rules = RULES.get(ch);
484475
if (rules == null) {
485476
continue;
486477
}
487-
488478
// use an EMPTY_LIST to avoid false positive warnings wrt potential null pointer access
489479
final List<Branch> nextBranches = branching ? new ArrayList<>() : Collections.emptyList();
490-
491480
for (final Rule rule : rules) {
492481
if (rule.matches(inputContext)) {
493482
if (branching) {
@@ -512,7 +501,6 @@ private String[] soundex(final String source, final boolean branching) {
512501
nextBranches.add(nextBranch);
513502
}
514503
}
515-
516504
if (branching) {
517505
currentBranches.clear();
518506
currentBranches.addAll(nextBranches);
@@ -521,17 +509,14 @@ private String[] soundex(final String source, final boolean branching) {
521509
break;
522510
}
523511
}
524-
525512
lastChar = ch;
526513
}
527-
528514
final String[] result = new String[currentBranches.size()];
529515
int index = 0;
530516
for (final Branch branch : currentBranches) {
531517
branch.finish();
532518
result[index++] = branch.toString();
533519
}
534-
535520
return result;
536521
}
537522
}

0 commit comments

Comments
 (0)