diff --git a/rewrite-core/src/main/java/org/openrewrite/internal/NameCaseConvention.java b/rewrite-core/src/main/java/org/openrewrite/internal/NameCaseConvention.java index 3848e0b712c..00d318e96d3 100755 --- a/rewrite-core/src/main/java/org/openrewrite/internal/NameCaseConvention.java +++ b/rewrite-core/src/main/java/org/openrewrite/internal/NameCaseConvention.java @@ -148,16 +148,19 @@ private static String lowerUnderscore(String str) { */ private static String toCamelCase(String str, boolean lowerCaseFirstLetter) { boolean allUpperCase = true; - for (char c : str.toCharArray()) { - if(Character.isLowerCase(c)) { + final int strLength = str.length(); + for (int i = 0; i < strLength; i++) { + final char c = str.charAt(i); + if (Character.isLowerCase(c)) { allUpperCase = false; + break; } } - if(allUpperCase) { + if (allUpperCase) { str = str.toLowerCase(); } - StringBuilder sb = new StringBuilder(str.length()); + StringBuilder sb = new StringBuilder(strLength); for (String s : CAMEL_CASE_SPLIT.split(str)) { String capitalize = StringUtils.capitalize(s); sb.append(capitalize);