[LANG-1557] Change a Pattern to a static final field, for not letting it compile each time the function invoked. (#542)
* Pattern_to_static_ * move the constants to head of the file. * Simplify private comment. Co-authored-by: Gary Gregory <garydgregory@users.noreply.github.com>
This commit is contained in:
parent
7852ed9d4d
commit
677604fb84
|
@ -179,6 +179,11 @@ public class StringUtils {
|
||||||
*/
|
*/
|
||||||
private static final int PAD_LIMIT = 8192;
|
private static final int PAD_LIMIT = 8192;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pattern used in {@link #stripAccents(String)}.
|
||||||
|
*/
|
||||||
|
private static final Pattern STRIP_ACCENTS_PATTERN = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); //$NON-NLS-1$
|
||||||
|
|
||||||
// Abbreviating
|
// Abbreviating
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -8215,11 +8220,10 @@ public class StringUtils {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); //$NON-NLS-1$
|
|
||||||
final StringBuilder decomposed = new StringBuilder(Normalizer.normalize(input, Normalizer.Form.NFD));
|
final StringBuilder decomposed = new StringBuilder(Normalizer.normalize(input, Normalizer.Form.NFD));
|
||||||
convertRemainingAccentCharacters(decomposed);
|
convertRemainingAccentCharacters(decomposed);
|
||||||
// Note that this doesn't correctly remove ligatures...
|
// Note that this doesn't correctly remove ligatures...
|
||||||
return pattern.matcher(decomposed).replaceAll(EMPTY);
|
return STRIP_ACCENTS_PATTERN.matcher(decomposed).replaceAll(EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// StripAll
|
// StripAll
|
||||||
|
|
Loading…
Reference in New Issue