MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / patternComplexity

Function patternComplexity

src/compute-engine/boxed-expression/match.ts:1327–1333  ·  view source on GitHub ↗

Compute a complexity score for a pattern operand. Simpler patterns (bare * wildcards) get lower scores and are preferred as identity terms.

(expr: Expression)

Source from the content-addressed store, hash-verified

1325 // (repeated) wildcard: this split fails — a different `j` may
1326 // still produce a capture consistent with the prior binding,
1327 // so treat it like a failed recursive match, not a success
1328 // with the capture silently dropped.
1329 const capture = captureWildcard(
1330 argName,
1331 captureOps(j),
1332 savedSubstitution
1333 );
1334
1335 result =
1336 capture === null

Callers 1

matchWithMissingTermsFunction · 0.85

Calls 5

isWildcardFunction · 0.90
isNumberFunction · 0.90
isSymbolFunction · 0.90
isStringFunction · 0.90
isFunctionFunction · 0.90

Tested by

no test coverage detected