Skip to content

Commit 1347ebe

Browse files
committed
Faster MutatingScope->getNodeKey()
1 parent 47789d7 commit 1347ebe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Analyser/MutatingScope.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,12 @@ public function getScopeNativeType(Expr $expr): Type
917917

918918
private function getNodeKey(Expr $node): string
919919
{
920-
$key = $this->exprPrinter->printExpr($node);
920+
// perf optimize for the most common path
921+
if ($node instanceof Variable) {
922+
return '$'.$node->name;
923+
}
921924

925+
$key = $this->exprPrinter->printExpr($node);
922926
$attributes = $node->getAttributes();
923927
if (
924928
$node instanceof Node\FunctionLike

0 commit comments

Comments
 (0)