|
@@ -5,9 +5,10 @@
|
|
|
|
|
|
package me.shedaniel.rei.client;
|
|
|
|
|
|
+import com.google.common.base.CharMatcher;
|
|
|
+
|
|
|
import java.util.Locale;
|
|
|
import java.util.function.Function;
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
|
|
public class SearchArgument {
|
|
|
|
|
@@ -17,7 +18,6 @@ public class SearchArgument {
|
|
|
public final Function<String, Boolean> INCLUDE = s -> search(text, s);
|
|
|
public final Function<String, Boolean> NOT_INCLUDE = s -> !search(text, s);
|
|
|
private boolean include;
|
|
|
- private Pattern pattern;
|
|
|
|
|
|
public SearchArgument(ArgumentType argumentType, String text, boolean include) {
|
|
|
this(argumentType, text, include, true);
|
|
@@ -29,10 +29,14 @@ public class SearchArgument {
|
|
|
this.include = include;
|
|
|
}
|
|
|
|
|
|
- public static boolean search(CharSequence pattern, CharSequence text) {
|
|
|
+ public static boolean search(CharSequence pattern, String text) {
|
|
|
int patternLength = pattern.length();
|
|
|
if (patternLength == 0)
|
|
|
return true;
|
|
|
+ if (patternLength > text.length())
|
|
|
+ return false;
|
|
|
+ if (!CharMatcher.ascii().matchesAllOf(text) || !CharMatcher.ascii().matchesAllOf(pattern))
|
|
|
+ return text.contains(pattern);
|
|
|
int shift[] = new int[256];
|
|
|
for(int k = 0; k < 256; k++)
|
|
|
shift[k] = patternLength;
|