Skip to content

Commit b805405

Browse files
committed
TRegex: replace usages of generic Predicate with IntPredicate
1 parent 48fbe97 commit b805405

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/RegexLexer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import java.util.LinkedHashMap;
4545
import java.util.List;
4646
import java.util.Map;
47-
import java.util.function.Predicate;
47+
import java.util.function.IntPredicate;
4848

4949
import org.graalvm.collections.EconomicSet;
5050

@@ -557,7 +557,7 @@ protected boolean lookahead(String match) {
557557
return pattern.regionMatches(position, match, 0, match.length());
558558
}
559559

560-
protected boolean lookahead(Predicate<Character> predicate, int length) {
560+
protected boolean lookahead(IntPredicate predicate, int length) {
561561
if (pattern.length() - position < length) {
562562
return false;
563563
}
@@ -588,7 +588,7 @@ protected boolean consumingLookahead(String match) {
588588
return matches;
589589
}
590590

591-
protected boolean consumingLookahead(Predicate<Character> predicate, int length) {
591+
protected boolean consumingLookahead(IntPredicate predicate, int length) {
592592
final boolean matches = lookahead(predicate, length);
593593
if (matches) {
594594
position += length;
@@ -603,19 +603,19 @@ protected boolean lookbehind(char c) {
603603
return pattern.charAt(position - 1) == c;
604604
}
605605

606-
protected int count(Predicate<Character> predicate) {
606+
protected int count(IntPredicate predicate) {
607607
return count(predicate, position, pattern.length());
608608
}
609609

610-
protected int countUpTo(Predicate<Character> predicate, int max) {
610+
protected int countUpTo(IntPredicate predicate, int max) {
611611
return count(predicate, position, (int) Math.min(((long) position) + max, pattern.length()));
612612
}
613613

614-
protected int countFrom(Predicate<Character> predicate, int fromIndex) {
614+
protected int countFrom(IntPredicate predicate, int fromIndex) {
615615
return count(predicate, fromIndex, pattern.length());
616616
}
617617

618-
protected int count(Predicate<Character> predicate, int fromIndex, int toIndex) {
618+
protected int count(IntPredicate predicate, int fromIndex, int toIndex) {
619619
for (int i = fromIndex; i < toIndex; i++) {
620620
if (!predicate.test(pattern.charAt(i))) {
621621
return i - fromIndex;

regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/flavors/RubyRegexParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import java.util.List;
5454
import java.util.Map;
5555
import java.util.Optional;
56-
import java.util.function.Predicate;
56+
import java.util.function.IntPredicate;
5757

5858
import org.graalvm.collections.Pair;
5959

@@ -457,15 +457,15 @@ private int consumeChar() {
457457
return c;
458458
}
459459

460-
private String getMany(Predicate<Integer> pred) {
460+
private String getMany(IntPredicate pred) {
461461
StringBuilder out = new StringBuilder();
462462
while (!atEnd() && pred.test(curChar())) {
463463
out.appendCodePoint(consumeChar());
464464
}
465465
return out.toString();
466466
}
467467

468-
private String getUpTo(int count, Predicate<Integer> pred) {
468+
private String getUpTo(int count, IntPredicate pred) {
469469
StringBuilder out = new StringBuilder();
470470
int found = 0;
471471
while (found < count && !atEnd() && pred.test(curChar())) {

0 commit comments

Comments
 (0)