Skip to content

Commit 0fe77bb

Browse files
regex optimization (#305)
1 parent c14447e commit 0fe77bb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

aws-xray-recorder-sdk-aws-sdk-core/src/main/java/com/amazonaws/xray/utils/StringTransform.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515

1616
package com.amazonaws.xray.utils;
1717

18+
import java.util.regex.Pattern;
19+
1820
/**
1921
* @deprecated For internal use only.
2022
*/
2123
@Deprecated
2224
@SuppressWarnings("checkstyle:HideUtilityClassConstructor")
2325
public class StringTransform {
24-
private static final String REGEX = "([a-z])([A-Z]+)";
26+
private static final Pattern REGEX = Pattern.compile("([a-z])([A-Z]+)");
2527
private static final String REPLACE = "$1_$2";
2628

2729
public static String toSnakeCase(String camelCase) {
28-
return camelCase.replaceAll(REGEX, REPLACE).toLowerCase();
30+
return REGEX.matcher(camelCase).replaceAll(REPLACE).toLowerCase();
2931
}
3032
}

0 commit comments

Comments
 (0)