Skip to content

Commit 3408a97

Browse files
staabmondrejmirtes
authored andcommitted
Faster Scope->shouldInvalidateExpression()
1 parent 877d900 commit 3408a97

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Analyser/MutatingScope.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,6 +3500,11 @@ private function shouldInvalidateExpression(string $exprStringToInvalidate, Expr
35003500
return false;
35013501
}
35023502

3503+
// Variables will not contain traversable expressions. skip the NodeFinder overhead
3504+
if ($expr instanceof Variable && is_string($expr->name)) {
3505+
return $exprStringToInvalidate === $this->getNodeKey($expr);
3506+
}
3507+
35033508
$nodeFinder = new NodeFinder();
35043509
$expressionToInvalidateClass = get_class($exprToInvalidate);
35053510
$found = $nodeFinder->findFirst([$expr], function (Node $node) use ($expressionToInvalidateClass, $exprStringToInvalidate): bool {

0 commit comments

Comments
 (0)