提交 35bd00be 编写于 作者: P Philippe Marschall 提交者: Stephane Nicoll

Remove String#toCharArray from ScriptUtils

ScriptUtils contains two calls to String#toCharArray for the sole
purpose to iterating over all chars in a String. Not only is this
unnecessary and can be replaced with String#charAt it also causes
additional allocator and heap pressure because String#toCharArray
rather than returning the backing array (which is gone in Java 9)
creates a copy.

This commit contains the following changes:

 - remove String#toCharArray from ScriptUtils and replace with
   String#charAt

Issue: SPR-15075
上级 1ab0916b
......@@ -178,9 +178,8 @@ public abstract class ScriptUtils {
boolean inSingleQuote = false;
boolean inDoubleQuote = false;
boolean inEscape = false;
char[] content = script.toCharArray();
for (int i = 0; i < script.length(); i++) {
char c = content[i];
char c = script.charAt(i);
if (inEscape) {
inEscape = false;
sb.append(c);
......@@ -342,9 +341,8 @@ public abstract class ScriptUtils {
*/
public static boolean containsSqlScriptDelimiters(String script, String delim) {
boolean inLiteral = false;
char[] content = script.toCharArray();
for (int i = 0; i < script.length(); i++) {
if (content[i] == '\'') {
if (script.charAt(i) == '\'') {
inLiteral = !inLiteral;
}
if (!inLiteral && script.startsWith(delim, i)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册