WEB-61150 isQuotedString: improve performance.

GitOrigin-RevId: 64c3060db9242a5b268f080ef992ab500631a719
This commit is contained in:
Piotr Tomiak
2023-05-25 11:16:33 +03:00
committed by intellij-monorepo-bot
parent 9e854c9d5a
commit f4ea6a80ec

View File

@@ -404,7 +404,11 @@ public class StringUtilRt {
*/
@Contract(pure = true)
public static boolean isQuotedString(@NotNull String s) {
return s.length() > 1 && (s.charAt(0) == '\'' || s.charAt(0) == '\"') && s.charAt(0) == s.charAt(s.length() - 1);
int length = s.length();
if (length <= 1) return false;
char firstChar = s.charAt(0);
if (firstChar != '\'' && firstChar != '\"') return false;
return firstChar == s.charAt(length - 1);
}
@NotNull