LibRegex: Flatten capture group list in MatchState

This makes copying the capture group COWVector significantly cheaper,
as we no longer have to run any constructors for it - just memcpy.
This commit is contained in:
Ali Mohammad Pur 2025-04-15 15:31:08 +02:00 committed by Andreas Kling
commit 76f5dce3db
Notes: github-actions[bot] 2025-04-18 15:10:37 +00:00
14 changed files with 98 additions and 87 deletions

View file

@ -228,7 +228,6 @@ PatternErrorOr<Component> Component::compile(Utf8View const& input, PatternParse
auto flags = regex::RegexOptions<ECMAScriptFlags> {
(regex::ECMAScriptFlags)regex::AllFlags::SingleMatch
| (regex::ECMAScriptFlags)regex::AllFlags::Global
| (regex::ECMAScriptFlags)regex::AllFlags::SkipTrimEmptyMatches
| regex::ECMAScriptFlags::BrowserExtended
};
@ -288,7 +287,7 @@ Component::Result Component::create_match_result(String const& input, regex::Reg
// 4. Let index be 1.
// 5. While index is less than Get(execResult, "length"):
for (size_t index = 1; index <= exec_result.n_capture_groups; ++index) {
auto const& capture = exec_result.capture_group_matches[0][index];
auto const& capture = exec_result.capture_group_matches[0][index - 1];
// 1. Let name be components group name list[index 1].
auto name = group_name_list[index - 1];