1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:57:35 +00:00

LibRegex+LibJS: Avoid searching for more than one match in JS RegExps

All of JS's regular expression APIs only want a single match, so avoid
trying to produce more (which will be discarded anyway).
This commit is contained in:
Ali Mohammad Pur 2022-02-04 19:29:26 +03:30 committed by Andreas Kling
parent 4c506f91fe
commit 2b028f6faa
5 changed files with 28 additions and 5 deletions

View file

@ -81,10 +81,11 @@ enum __RegexAllFlags {
__Regex_Sticky = __Regex_Global << 11, // Force the pattern to only match consecutive matches from where the previous match ended.
__Regex_Multiline = __Regex_Global << 12, // Handle newline characters. Match each line, one by one.
__Regex_SkipTrimEmptyMatches = __Regex_Global << 13, // Do not remove empty capture group results.
__Regex_Internal_Stateful = __Regex_Global << 14, // Internal flag; enables stateful matches.
__Regex_Internal_BrowserExtended = __Regex_Global << 15, // Internal flag; enable browser-specific ECMA262 extensions.
__Regex_Internal_ConsiderNewline = __Regex_Global << 16, // Internal flag; allow matchers to consider newlines as line separators.
__Regex_Last = __Regex_SkipTrimEmptyMatches
__Regex_SingleMatch = __Regex_Global << 14, // Stop after acquiring a single match.
__Regex_Internal_Stateful = __Regex_Global << 15, // Internal flag; enables stateful matches.
__Regex_Internal_BrowserExtended = __Regex_Global << 16, // Internal flag; enable browser-specific ECMA262 extensions.
__Regex_Internal_ConsiderNewline = __Regex_Global << 17, // Internal flag; allow matchers to consider newlines as line separators.
__Regex_Last = __Regex_SingleMatch
};
// Values for the cflags parameter to the regcomp() function: