RFR: 8311939: Excessive allocation of Matcher.groups array [v6]
Cristian Vat
duke at openjdk.org
Tue Aug 15 19:26:38 UTC 2023
> Reduces excessive allocation of Matcher.groups array when the original Pattern has no groups or less than 9 groups.
>
> Original clamping to 10 possibly due to documented behavior from javadoc:
> "In this class, \1 through \9 are always interpreted as back references, "
>
> Only with Matcher changes RegExTest.backRefTest fails when backreferences to non-existing groups are present.
> Added a match failure condition in Pattern that fixes failing tests.
>
> As per existing `java.util.regex.Pattern.BackRef#match`: "// If the referenced group didn't match, neither can this"
>
> A group that does not exist in the original Pattern can never match so neither can a backref to that group.
> If the group existed in the original Pattern then it would have had space allocated in Matcher.groups for that group index.
> So a group index outside groups array length must never match.
Cristian Vat has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
- Merge branch 'openjdk:master' into JDK-8311939
- review condition
- changes and test for CIBackRef
- remove new line
- reduce allocations also for Matcher.usePattern
- 8311939: Excessive allocation of Matcher.groups array
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/14894/files
- new: https://git.openjdk.org/jdk/pull/14894/files/37b18e0c..0538e25e
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=14894&range=05
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=14894&range=04-05
Stats: 64874 lines in 1702 files changed: 33516 ins; 19812 del; 11546 mod
Patch: https://git.openjdk.org/jdk/pull/14894.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/14894/head:pull/14894
PR: https://git.openjdk.org/jdk/pull/14894
More information about the core-libs-dev
mailing list