@@ -286,12 +286,6 @@ public char removeNext() {
286286 * <li>small sharp s, German</li>
287287 * </ul>
288288 */
289- private static final char [][] PREPROCESS_MAP = new char [][]{
290- {'\u00C4' , 'A' }, // capital a, umlaut mark
291- {'\u00DC' , 'U' }, // capital u, umlaut mark
292- {'\u00D6' , 'O' }, // capital o, umlaut mark
293- {'\u00DF' , 'S' } // small sharp s, German
294- };
295289
296290 /*
297291 * Returns whether the array contains the key, or not.
@@ -321,10 +315,8 @@ public String colognePhonetic(String text) {
321315 return null ;
322316 }
323317
324- text = preprocess (text );
325-
326- final CologneOutputBuffer output = new CologneOutputBuffer (text .length () * 2 );
327- final CologneInputBuffer input = new CologneInputBuffer (text .toCharArray ());
318+ final CologneInputBuffer input = new CologneInputBuffer (preprocess (text ));
319+ final CologneOutputBuffer output = new CologneOutputBuffer (input .length () * 2 );
328320
329321 char nextChar ;
330322
@@ -423,23 +415,27 @@ public boolean isEncodeEqual(final String text1, final String text2) {
423415 }
424416
425417 /**
426- * Converts the string to upper case and replaces germanic characters as defined in {@link #PREPROCESS_MAP}.
418+ * Converts the string to upper case and replaces Germanic umlaut characters
427419 */
428- private String preprocess (String text ) {
429- text = text .toUpperCase (Locale .GERMAN );
430-
431- final char [] chrs = text .toCharArray ();
420+ private char [] preprocess (String text ) {
421+ // This converts German small sharp s (Eszett) to SS
422+ final char [] chrs = text .toUpperCase (Locale .GERMAN ).toCharArray ();
432423
433424 for (int index = 0 ; index < chrs .length ; index ++) {
434- if (chrs [index ] > 'Z' ) {
435- for (final char [] element : PREPROCESS_MAP ) {
436- if (chrs [index ] == element [0 ]) {
437- chrs [index ] = element [1 ];
438- break ;
439- }
440- }
425+ switch (chrs [index ]) {
426+ case '\u00C4' : // capital A, umlaut mark
427+ chrs [index ] = 'A' ;
428+ break ;
429+ case '\u00DC' : // capital U, umlaut mark
430+ chrs [index ] = 'U' ;
431+ break ;
432+ case '\u00D6' : // capital O, umlaut mark
433+ chrs [index ] = 'O' ;
434+ break ;
435+ default :
436+ break ;
441437 }
442438 }
443- return new String ( chrs ) ;
439+ return chrs ;
444440 }
445441}
0 commit comments