Skip to content

<regex>: Avoid generating no-op NFA nodes #5962

@muellerj2

Description

@muellerj2

The NFA nodes of type _N_nop, _N_group and _N_end_group do not result in any changes to the match state in the matcher. However, processing them still requires some time. Going by the benchmarks in #5939, it seems about 2.5 ns are spent on my machine whenever when such a node is encountered by the matcher; see, e.g., the 37 % (relative) / 470 ns (absolute) increase in running time when matching the pattern (?:a)* to 100 a's compared to a*.

Note that these NFA nodes do usually serve some purpose during regex parsing, so resolving this issue requires some careful changes to the parser logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceMust go fasterregexmeow is a substring of homeowner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions