-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `Pattern.programSize()` and `Matcher.programSize()` This PR exposes `Pattern.programSize()` and `Matcher.programSize()` public API. The program size represents a very approximate measure of a regexp's "cost". Larger numbers are more expensive than smaller numbers. Similar to the canonical C++ implementation, re2j will return the program size as the number of instructions of the regex program without making any promises or claims except "larger is more expensive". Context: The need for this change arose from cross-language projects, such as gRPC and CEL. gRPC needs to configure the maximum size of regex programs in CEL to the same number across all languages. While it's possible in CEL-Cpp and gRPC-Cpp, CEL-Java doesn't provide the same configuration option simply because the program size is not available in re2j. In Go, the number of instruction is available in Go via the length of https://pkg.go.dev/regexp/syntax#Prog.Inst. * googleJavaFormat
- Loading branch information
Showing
6 changed files
with
90 additions
and
1 deletion.
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
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
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