From b95f1179923059663d2553f0155c3af6dcbbd28f Mon Sep 17 00:00:00 2001 From: Kim Seon Woo <69591622+seonwoo960000@users.noreply.github.com> Date: Sun, 31 Dec 2023 16:57:12 +0800 Subject: [PATCH] Add break statement to toCamelCase (#3871) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add break statement * Change charArray conversion to index access --------- Co-authored-by: 김선우 --- .../org/openrewrite/internal/NameCaseConvention.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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);