8305785: Avoid redundant HashMap.containsKey call in java.util.regex

Reviewed-by: stsypanov, jpai
This commit is contained in:
Andrey Turbanov 2023-05-22 10:27:13 +00:00
parent 8011ba74a2
commit 6b65e5754c
2 changed files with 10 additions and 7 deletions

View file

@ -2712,14 +2712,15 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
if (read() != '<')
throw error("\\k is not followed by '<' for named capturing group");
String name = groupname(read());
if (!namedGroupsMap().containsKey(name))
Integer number = namedGroupsMap().get(name);
if (number == null)
throw error("named capturing group <" + name + "> does not exist");
if (create) {
hasGroupRef = true;
if (has(CASE_INSENSITIVE))
root = new CIBackRef(namedGroupsMap().get(name), has(UNICODE_CASE));
root = new CIBackRef(number, has(UNICODE_CASE));
else
root = new BackRef(namedGroupsMap().get(name));
root = new BackRef(number);
}
return -1;
case 'l':