MCPcopy Create free account
hub / github.com/dlclark/regexp2 / reduceBackreferenceConditional

Method reduceBackreferenceConditional

syntax/tree.go:530–540  ·  view source on GitHub ↗

Optimizations for backreference conditionals.

()

Source from the content-addressed store, hash-verified

528
529// Optimizations for backreference conditionals.
530func (n *RegexNode) reduceBackreferenceConditional() *RegexNode {
531 // This isn't so much an optimization as it is changing the tree for consistency. We want
532 // all engines to be able to trust that every backreference conditional will have two children,
533 // even though it's optional in the syntax. If it's missing a "not matched" branch,
534 // we add one that will match empty.
535 if len(n.Children) == 1 {
536 n.addChild(&RegexNode{T: NtEmpty, Options: n.Options})
537 }
538
539 return n
540}
541
542// / <summary>Optimizations for expression conditionals.</summary>
543func (n *RegexNode) reduceExpressionConditional() *RegexNode {

Callers 1

reduceMethod · 0.95

Calls 1

addChildMethod · 0.95

Tested by

no test coverage detected