-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Omit leading empty matches from Pattern.split, improve performance
Fixes #131. This change modifies Pattern.split to omit a leading empty match. This behavior was specified in JDK8 and brings RE2/J split into line with more recent JDK implementations. Furthermore, the split function no longer needs determine the number of matches before assembling the result. The upshot is that the number of find() calls is halved in many cases. The benchmark in the previous change shows a significant improvement. Reference impl (JDK): BenchmarkSplit.benchmarkSplit JDK avgt 5 14.217 ± 0.410 us/op RE2J (before): BenchmarkSplit.benchmarkSplit RE2J avgt 5 95.807 ± 6.737 us/op RE2J (after): BenchmarkSplit.benchmarkSplit RE2J avgt 5 49.092 ± 0.717 us/op
- Loading branch information
Showing
2 changed files
with
60 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters