From f383b6c490bd55993e37c2940613315501838e2e Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Sat, 4 Jan 2014 12:50:19 -0600 Subject: Use region matching instead of sub-strings. Addresses BUKKIT-5275 --- src/main/java/org/bukkit/util/StringUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/java/org') 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. * Note: the collection may be modified before this is thrown */ - public static > T copyPartialMatches(final String token, final Iterable originals, final T collection) throws UnsupportedOperationException, IllegalArgumentException { + public static > T copyPartialMatches(final String token, final Iterable 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()); } } -- cgit v1.2.3