Skip to content

Improve handling of lazy loops in regex source generator / compiler #68415

@stephentoub

Description

@stephentoub

Lazy loops currently push/pop more state on to the backtracking stack than is generally necessary. This can be improved.

// PERFORMANCE TODO:
// If we're inside of an outer loop, all of this state needs to be pushed on to the backtracking
// stack, since a subsequent iteration of that outer loop could overwrite it. But if we're
// not inside of another loop, locals dedicated to this construct can store the data, as nothing
// else will overwrite them before we need them again. There are lots of combinations to think
// through in this case, however, so it's something to follow-up on.
// Additionally, we only need sawEmpty if it's even possible for the child to match empty,
// which we can compute using node.Child(0).ComputeMinLength() == 0. We should be able to
// avoid all of the checks related to sawEmpty if ComputeMinLength() > 0, and potentially
// storing startingPos either.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions