Avoid unnecessary String instantiation in StringUtils.deleteAny()

This commit avoids unnecessary String instantiation in
StringUtils.deleteAny() if nothing was deleted from the
input string.

Closes gh-24924
This commit is contained in:
Johnny Lim
2020-04-18 01:44:16 +09:00
committed by GitHub
parent 87f28ce48e
commit 87fa2c3b97

View File

@@ -461,6 +461,9 @@ public abstract class StringUtils {
result[lastCharIndex++] = c;
}
}
if (lastCharIndex == inString.length()) {
return inString;
}
return new String(result, 0, lastCharIndex);
}