This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new 677604f [LANG-1557] Change a Pattern to a static final field, for not
letting it compile each time the function invoked. (#542)
677604f is described below
commit 677604fb8439a39e1f97343026c64928afcb121a
Author: XenoAmess <[email protected]>
AuthorDate: Sun Jun 14 21:46:53 2020 +0800
[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 <[email protected]>
---
src/main/java/org/apache/commons/lang3/StringUtils.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java
b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 7dc9286..507cba0 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -179,6 +179,11 @@ public class StringUtils {
*/
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
//-----------------------------------------------------------------------
/**
@@ -8215,11 +8220,10 @@ public class StringUtils {
if (input == null) {
return null;
}
- final Pattern pattern =
Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); //$NON-NLS-1$
final StringBuilder decomposed = new
StringBuilder(Normalizer.normalize(input, Normalizer.Form.NFD));
convertRemainingAccentCharacters(decomposed);
// Note that this doesn't correctly remove ligatures...
- return pattern.matcher(decomposed).replaceAll(EMPTY);
+ return STRIP_ACCENTS_PATTERN.matcher(decomposed).replaceAll(EMPTY);
}
// StripAll