Skip to content

Commit 007ddf1

Browse files
committed
Rewrite DaitchMokotoffSoundex.soundex(String) using String.join()
1 parent 83e80d7 commit 007ddf1

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The <action> type attribute can be add,update,fix,remove.
4545
<body>
4646
<release version="1.17.2" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required.">
4747
<!-- FIX -->
48+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Rewrite DaitchMokotoffSoundex.soundex(String) using String.join().</action>
4849
<!-- ADD -->
4950
<!-- UPDATE -->
5051
<action type="update" dev="ggregory" due-to="Dependabot">Bump org.apache.commons:commons-lang3 from 3.14.0 to 3.15.0 #296.</action>

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,7 @@ public String encode(final String source) {
441441
* if a character is not mapped
442442
*/
443443
public String soundex(final String source) {
444-
final String[] branches = soundex(source, true);
445-
final StringBuilder sb = new StringBuilder();
446-
int index = 0;
447-
for (final String branch : branches) {
448-
sb.append(branch);
449-
if (++index < branches.length) {
450-
sb.append('|');
451-
}
452-
}
453-
return sb.toString();
444+
return String.join("|", soundex(source, true));
454445
}
455446

456447
/**

0 commit comments

Comments
 (0)