1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00
serenity/Userland/Libraries/LibRegex
Ali Mohammad Pur 4e69eb89e8 LibRegex: Generate a search tree when patterns would benefit from it
This takes the previous alternation optimisation and applies it to all
the alternation blocks instead of just the few instructions at the
start.
By generating a trie of instructions, all logically equivalent
instructions will be consolidated into a single node, allowing the
engine to avoid checking the same thing multiple times.
For instance, given the pattern /abc|ac|ab/, this optimisation would
generate the following tree:
    - a
    | - b
    | | - c
    | | | - <accept>
    | | - <accept>
    | - c
    | | - <accept>
which will attempt to match 'a' or 'b' only once, and would also limit
the number of backtrackings performed in case alternatives fails to
match.

This optimisation is currently gated behind a simple cost model that
estimates the number of instructions generated, which is pessimistic for
small patterns, though the change in performance in such patterns is not
particularly large.
2023-07-31 05:31:33 +02:00
..
C LibRegex: Tweak get_error() function 2023-01-04 20:04:57 +01:00
CMakeLists.txt Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
Forward.h LibRegex: Don't push LibRegex's "Error" into the global namespace 2021-11-08 00:35:27 +01:00
Regex.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
RegexByteCode.cpp LibRegex: Add the literal string search optimisation 2023-07-31 05:31:33 +02:00
RegexByteCode.h LibRegex: Generate a search tree when patterns would benefit from it 2023-07-31 05:31:33 +02:00
RegexBytecodeStreamOptimizer.h LibRegex: Make codegen+optimisation for alternatives much faster 2022-02-20 11:53:59 +01:00
RegexDebug.h Everywhere: Move AK/Debug.h include to using files or remove 2023-01-02 20:27:20 -05:00
RegexDefs.h LibC+LibRegex: Move regex_defs.h from LibC to LibRegex 2023-06-27 12:40:38 +02:00
RegexError.h LibC+LibRegex: Move regex_defs.h from LibC to LibRegex 2023-06-27 12:40:38 +02:00
RegexLexer.cpp Everywhere: Use default StringView constructor over nullptr 2022-07-12 23:11:35 +02:00
RegexLexer.h Everywhere: Use default StringView constructor over nullptr 2022-07-12 23:11:35 +02:00
RegexMatch.h LibRegex: Add the literal string search optimisation 2023-07-31 05:31:33 +02:00
RegexMatcher.cpp LibRegex: Add the literal string search optimisation 2023-07-31 05:31:33 +02:00
RegexMatcher.h LibRegex: Add the literal string search optimisation 2023-07-31 05:31:33 +02:00
RegexOptimizer.cpp LibRegex: Generate a search tree when patterns would benefit from it 2023-07-31 05:31:33 +02:00
RegexOptions.h LibC+LibRegex: Move regex_defs.h from LibC to LibRegex 2023-06-27 12:40:38 +02:00
RegexParser.cpp LibRegex: Assign unique serial IDs to checkpoints 2023-07-14 08:59:19 +02:00
RegexParser.h LibRegex: Add the literal string search optimisation 2023-07-31 05:31:33 +02:00