[go: nahoru, domu]

Skip to content

Commit

Permalink
Use c.g.re2j.Pattern, not c.g.re2j.RE2 in Benchmark matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
sjamesr committed May 18, 2018
1 parent 9d97497 commit 602eab4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions javatests/com/google/re2j/Benchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,29 @@ private Matcher compile(String re) {
// The JDK implementation appears dramatically faster for these
// inputs, possibly due to its use of right-to-left matching via
// Boyer-Moore for anchored patterns. We should totally do that.
final Pattern r = Pattern.compile(re);
final Pattern p = Pattern.compile(re);
return new Matcher() {
@Override
public boolean match(String input) {
return r.matcher(input).find();
return p.matcher(input).find();
}

@Override
public String replaceAll(String input, String replacement) {
return r.matcher(input).replaceAll(replacement);
return p.matcher(input).replaceAll(replacement);
}
};
} else { // com.google.re2
final RE2 r = RE2.compile(re);
final com.google.re2j.Pattern p = com.google.re2j.Pattern.compile(re);
return new Matcher() {
@Override
public boolean match(String input) {
return r.match(input);
return p.matcher(input).find();
}

@Override
public String replaceAll(String input, String replacement) {
return r.replaceAll(input, replacement);
return p.matcher(input).replaceAll(replacement);
}
};
}
Expand Down

0 comments on commit 602eab4

Please sign in to comment.