diff options
author | Wesley Wolfe <weswolf@aol.com> | 2014-01-04 12:50:19 -0600 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2014-01-04 12:50:19 -0600 |
commit | f383b6c490bd55993e37c2940613315501838e2e (patch) | |
tree | 89f16e2a95e0bab23b813988a8319baef26999a7 | |
parent | 81d3f6367e0f7fc76fc6f7e3625c1d12819a7807 (diff) | |
download | bukkit-f383b6c490bd55993e37c2940613315501838e2e.tar bukkit-f383b6c490bd55993e37c2940613315501838e2e.tar.gz bukkit-f383b6c490bd55993e37c2940613315501838e2e.tar.lz bukkit-f383b6c490bd55993e37c2940613315501838e2e.tar.xz bukkit-f383b6c490bd55993e37c2940613315501838e2e.zip |
Use region matching instead of sub-strings. Addresses BUKKIT-5275
-rw-r--r-- | src/main/java/org/bukkit/util/StringUtil.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/util/StringUtil.java b/src/main/java/org/bukkit/util/StringUtil.java index ed309ccb..4a8753fd 100644 --- a/src/main/java/org/bukkit/util/StringUtil.java +++ b/src/main/java/org/bukkit/util/StringUtil.java @@ -21,7 +21,7 @@ public class StringUtil { * @throws IllegalArgumentException if originals contains a null element. * <b>Note: the collection may be modified before this is thrown</b> */ - public static <T extends Collection<String>> T copyPartialMatches(final String token, final Iterable<String> originals, final T collection) throws UnsupportedOperationException, IllegalArgumentException { + public static <T extends Collection<? super String>> T copyPartialMatches(final String token, final Iterable<String> originals, final T collection) throws UnsupportedOperationException, IllegalArgumentException { Validate.notNull(token, "Search token cannot be null"); Validate.notNull(collection, "Collection cannot be null"); Validate.notNull(originals, "Originals cannot be null"); @@ -36,7 +36,7 @@ public class StringUtil { } /** - * This method uses a substring to check case-insensitive equality. This + * This method uses a region to check case-insensitive equality. This * means the internal array does not need to be copied like a * toLowerCase() call would. * @@ -52,6 +52,6 @@ public class StringUtil { if (string.length() < prefix.length()) { return false; } - return string.substring(0, prefix.length()).equalsIgnoreCase(prefix); + return string.regionMatches(true, 0, prefix, 0, prefix.length()); } } |