Skip to content

Commit f672d69

Browse files
committed
resume the min() call
1 parent c241575 commit f672d69

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mug/src/main/java/com/google/mu/util/Substring.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static com.google.mu.util.InternalCollectors.toImmutableList;
1818
import static com.google.mu.util.stream.MoreStreams.whileNotNull;
1919
import static java.lang.Math.max;
20+
import static java.lang.Math.min;
2021
import static java.util.Comparator.comparingInt;
2122
import static java.util.Objects.requireNonNull;
2223
import static java.util.regex.Pattern.compile;
@@ -3146,11 +3147,12 @@ private Pattern look(Predicate<Match> condition) {
31463147
Last original = this;
31473148
return new Last() {
31483149
@Override Match match(String input, int fromIndex, int endIndex) {
3149-
for (int i = endIndex; i >= fromIndex; i--) {
3150+
for (int i = endIndex; i >= fromIndex; ) {
31503151
Match match = original.match(input, fromIndex, i);
31513152
if (match == null || condition.test(match)) {
31523153
return match;
31533154
}
3155+
i = min(match.endIndex - 1, i - 1);
31543156
}
31553157
return null;
31563158
}

0 commit comments

Comments
 (0)