Skip to content

Commit 16a0eea

Browse files
committed
Alphabetize for easier comparison with published algorithm
1 parent 387eba9 commit 16a0eea

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ public class ColognePhonetic implements StringEncoder {
183183

184184
// Predefined char arrays for better performance and less GC load
185185
private static final char[] AEIJOUY = new char[] { 'A', 'E', 'I', 'J', 'O', 'U', 'Y' };
186-
private static final char[] SCZ = new char[] { 'S', 'C', 'Z' };
187-
private static final char[] WFPV = new char[] { 'W', 'F', 'P', 'V' };
186+
private static final char[] CSZ = new char[] { 'C', 'S', 'Z' };
187+
private static final char[] FPVW = new char[] { 'F', 'P', 'V', 'W' };
188188
private static final char[] GKQ = new char[] { 'G', 'K', 'Q' };
189189
private static final char[] CKQ = new char[] { 'C', 'K', 'Q' };
190190
private static final char[] AHKLOQRUX = new char[] { 'A', 'H', 'K', 'L', 'O', 'Q', 'R', 'U', 'X' };
191191
private static final char[] SZ = new char[] { 'S', 'Z' };
192-
private static final char[] AHOUKQX = new char[] { 'A', 'H', 'O', 'U', 'K', 'Q', 'X' };
193-
private static final char[] TDX = new char[] { 'T', 'D', 'X' };
192+
private static final char[] AHKOQUX = new char[] { 'A', 'H', 'K', 'O', 'Q', 'U', 'X' };
193+
private static final char[] DTX = new char[] { 'D', 'T', 'X' };
194194

195195
/**
196196
* This class is not thread-safe; the field {@link #length} is mutable.
@@ -336,9 +336,9 @@ public String colognePhonetic(String text) {
336336
code = '0';
337337
} else if (chr == 'B' || (chr == 'P' && nextChar != 'H')) {
338338
code = '1';
339-
} else if ((chr == 'D' || chr == 'T') && !arrayContains(SCZ, nextChar)) {
339+
} else if ((chr == 'D' || chr == 'T') && !arrayContains(CSZ, nextChar)) {
340340
code = '2';
341-
} else if (arrayContains(WFPV, chr)) {
341+
} else if (arrayContains(FPVW, chr)) {
342342
code = '3';
343343
} else if (arrayContains(GKQ, chr)) {
344344
code = '4';
@@ -355,13 +355,13 @@ public String colognePhonetic(String text) {
355355
code = '8';
356356
}
357357
} else {
358-
if (arrayContains(SZ, lastChar) || !arrayContains(AHOUKQX, nextChar)) {
358+
if (arrayContains(SZ, lastChar) || !arrayContains(AHKOQUX, nextChar)) {
359359
code = '8';
360360
} else {
361361
code = '4';
362362
}
363363
}
364-
} else if (arrayContains(TDX, chr)) {
364+
} else if (arrayContains(DTX, chr)) {
365365
code = '8';
366366
} else if (chr == 'R') {
367367
code = '7';

0 commit comments

Comments
 (0)