mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-08 02:58:33 +00:00
[LANG-1679] Improve performance of StringUtils.unwrap(String, String) (#844)
This commit is contained in:
parent
97e1f091af
commit
944608b854
@ -9425,13 +9425,7 @@ public static String unwrap(final String str, final String wrapToken) {
|
||||
}
|
||||
|
||||
if (startsWith(str, wrapToken) && endsWith(str, wrapToken)) {
|
||||
final int startIndex = str.indexOf(wrapToken);
|
||||
final int endIndex = str.lastIndexOf(wrapToken);
|
||||
final int wrapLength = wrapToken.length();
|
||||
|
||||
if (startIndex != -1 && endIndex != -1) {
|
||||
return str.substring(startIndex + wrapLength, endIndex);
|
||||
}
|
||||
return str.substring(wrapToken.length(), str.lastIndexOf(wrapToken));
|
||||
}
|
||||
|
||||
return str;
|
||||
|
Loading…
x
Reference in New Issue
Block a user