Skip to content

Commit e49d00b

Browse files
author
Mickaël Remars
committed
Merge branch 'master' into tmp
2 parents 57a57c0 + b3bce7b commit e49d00b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+997
-264
lines changed

.github/workflows/cobertura.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Code coverage
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
coverage:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up JDK 8
12+
uses: actions/setup-java@v2
13+
with:
14+
java-version: '8'
15+
distribution: 'adopt'
16+
- name: Generate Coverage Data
17+
uses: eskatos/gradle-command-action@v1
18+
with:
19+
arguments: cobertura
20+
wrapper-cache-enabled: true
21+
dependencies-cache-enabled: true
22+
configuration-cache-enabled: true
23+
- uses: codecov/codecov-action@v1
24+
with:
25+
files: build/reports/cobertura/coverage.xml
26+
fail_ci_if_error: false

.github/workflows/gradle.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Java CI
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
tests:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up JDK 8
12+
uses: actions/setup-java@v2
13+
with:
14+
java-version: '8'
15+
distribution: 'adopt'
16+
- name: Run Gradle Tests
17+
uses: eskatos/gradle-command-action@v1
18+
with:
19+
arguments: check
20+
wrapper-cache-enabled: true
21+
dependencies-cache-enabled: true
22+
configuration-cache-enabled: true

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

LICENSE.header

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Copyright (c) ${year} The Go Authors. All rights reserved.
2+
3+
Use of this source code is governed by a BSD-style
4+
license that can be found in the LICENSE file.
5+

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
RE2/J: linear time regular expression matching in Java
22
======================================================
33

4-
[![Build Status](https://travis-ci.org/google/re2j.svg?branch=master)](https://travis-ci.org/google/re2j)
5-
[![Coverage Status](https://coveralls.io/repos/github/google/re2j/badge.svg)](https://coveralls.io/github/google/re2j)
4+
[![Build Status](https://github.com/google/re2j/actions/workflows/gradle.yaml/badge.svg?branch=master)](https://github.com/google/re2j/actions/workflows/gradle.yaml?query=branch%3Amaster)
5+
[![Coverage Status](https://codecov.io/gh/google/re2j/branch/master/graph/badge.svg?token=HL6dzvQ9kK)](https://codecov.io/gh/google/re2j)
66

77
RE2 is a regular expression engine that runs in time linear in the size of the
88
input. RE2/J is a port of RE2 to pure Java.
@@ -74,7 +74,7 @@ If you're using Maven, you can use the following snippet in your `pom.xml` to ge
7474
<dependency>
7575
<groupId>com.google.re2j</groupId>
7676
<artifactId>re2j</artifactId>
77-
<version>1.4</version>
77+
<version>1.6</version>
7878
</dependency>
7979
```
8080

benchmarks/src/main/java/com/google/re2j/benchmark/BenchmarkBacktrack.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
// Copyright 2019 Google Inc. All Rights Reserved.
2-
1+
/*
2+
* Copyright (c) 2020 The Go Authors. All rights reserved.
3+
*
4+
* Use of this source code is governed by a BSD-style
5+
* license that can be found in the LICENSE file.
6+
*/
37
package com.google.re2j.benchmark;
48

59
import org.openjdk.jmh.annotations.Benchmark;

benchmarks/src/main/java/com/google/re2j/benchmark/BenchmarkCompile.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
// Copyright 2019 Google Inc. All Rights Reserved.
2-
1+
/*
2+
* Copyright (c) 2020 The Go Authors. All rights reserved.
3+
*
4+
* Use of this source code is governed by a BSD-style
5+
* license that can be found in the LICENSE file.
6+
*/
37
package com.google.re2j.benchmark;
48

59
import org.openjdk.jmh.annotations.Benchmark;

benchmarks/src/main/java/com/google/re2j/benchmark/BenchmarkFullMatch.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
// Copyright 2019 Google Inc. All Rights Reserved.
2-
1+
/*
2+
* Copyright (c) 2020 The Go Authors. All rights reserved.
3+
*
4+
* Use of this source code is governed by a BSD-style
5+
* license that can be found in the LICENSE file.
6+
*/
37
package com.google.re2j.benchmark;
48

9+
import static java.nio.charset.StandardCharsets.UTF_8;
10+
511
import org.openjdk.jmh.annotations.Benchmark;
612
import org.openjdk.jmh.annotations.OutputTimeUnit;
713
import org.openjdk.jmh.annotations.Param;
@@ -19,8 +25,17 @@ public class BenchmarkFullMatch {
1925
@Param({"JDK", "RE2J"})
2026
private Implementations impl;
2127

28+
@Param({"true", "false"})
29+
private boolean binary;
30+
2231
private Implementations.Pattern pattern;
2332

33+
private String password = "password";
34+
private byte[] password_bytes = password.getBytes(UTF_8);
35+
36+
private String l0ngpassword = "l0ngpassword";
37+
private byte[] l0ngpassword_bytes = "l0ngpassword".getBytes(UTF_8);
38+
2439
@Setup
2540
public void setup() {
2641
pattern =
@@ -30,7 +45,8 @@ public void setup() {
3045

3146
@Benchmark
3247
public void matched(Blackhole bh) {
33-
Implementations.Matcher matcher = pattern.matcher("password");
48+
Implementations.Matcher matcher =
49+
binary ? pattern.matcher(password_bytes) : pattern.matcher(password);
3450
boolean matches = matcher.matches();
3551
if (!matches) {
3652
throw new AssertionError();
@@ -40,7 +56,8 @@ public void matched(Blackhole bh) {
4056

4157
@Benchmark
4258
public void notMatched(Blackhole bh) {
43-
Implementations.Matcher matcher = pattern.matcher("l0ngpassword");
59+
Implementations.Matcher matcher =
60+
binary ? pattern.matcher(l0ngpassword_bytes) : pattern.matcher(l0ngpassword);
4461
boolean matches = matcher.matches();
4562
if (matches) {
4663
throw new AssertionError();

benchmarks/src/main/java/com/google/re2j/benchmark/BenchmarkSubMatch.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
// Copyright 2019 Google Inc. All Rights Reserved.
2-
1+
/*
2+
* Copyright (c) 2020 The Go Authors. All rights reserved.
3+
*
4+
* Use of this source code is governed by a BSD-style
5+
* license that can be found in the LICENSE file.
6+
*/
37
package com.google.re2j.benchmark;
48

59
import org.openjdk.jmh.annotations.Benchmark;
@@ -23,8 +27,12 @@ public class BenchmarkSubMatch {
2327
@Param({"JDK", "RE2J"})
2428
private Implementations impl;
2529

26-
private String html =
27-
new String(readFile("google-maps-contact-info.html"), StandardCharsets.UTF_8);
30+
@Param({"true", "false"})
31+
private boolean binary;
32+
33+
byte[] bytes = readFile("google-maps-contact-info.html");
34+
private String html = new String(bytes, StandardCharsets.UTF_8);
35+
2836
private Implementations.Pattern pattern;
2937

3038
@Setup
@@ -34,7 +42,7 @@ public void setup() {
3442

3543
@Benchmark
3644
public void findPhoneNumbers(Blackhole bh) {
37-
Implementations.Matcher matcher = pattern.matcher(html);
45+
Implementations.Matcher matcher = binary ? pattern.matcher(bytes) : pattern.matcher(html);
3846
int count = 0;
3947
while (matcher.find()) {
4048
bh.consume(matcher.group());

benchmarks/src/main/java/com/google/re2j/benchmark/Implementations.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
// Copyright 2019 Google Inc. All Rights Reserved.
2-
1+
/*
2+
* Copyright (c) 2020 The Go Authors. All rights reserved.
3+
*
4+
* Use of this source code is governed by a BSD-style
5+
* license that can be found in the LICENSE file.
6+
*/
37
package com.google.re2j.benchmark;
48

59
public enum Implementations {
@@ -76,6 +80,8 @@ public static Pattern compile(Implementations impl, String pattern) {
7680

7781
public abstract Matcher matcher(String str);
7882

83+
public abstract Matcher matcher(byte[] bytes);
84+
7985
public static class JdkPattern extends Pattern {
8086

8187
private final java.util.regex.Pattern pattern;
@@ -88,6 +94,11 @@ public JdkPattern(String pattern) {
8894
public Matcher matcher(String str) {
8995
return new Matcher.JdkMatcher(pattern.matcher(str));
9096
}
97+
98+
@Override
99+
public Matcher matcher(byte[] bytes) {
100+
return new Matcher.JdkMatcher(pattern.matcher(new String(bytes)));
101+
}
91102
}
92103

93104
public static class Re2Pattern extends Pattern {
@@ -102,6 +113,11 @@ public Re2Pattern(String pattern) {
102113
public Matcher matcher(String str) {
103114
return new Matcher.Re2Matcher(pattern.matcher(str));
104115
}
116+
117+
@Override
118+
public Matcher matcher(byte[] bytes) {
119+
return new Matcher.Re2Matcher(pattern.matcher(bytes));
120+
}
105121
}
106122
}
107123
}

0 commit comments

Comments
 (0)