File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff 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 && !$ node ->name instanceof Expr) {
922+ return '$ ' . $ node ->name ;
923+ }
921924
925+ $ key = $ this ->exprPrinter ->printExpr ($ node );
922926 $ attributes = $ node ->getAttributes ();
923927 if (
924928 $ node instanceof Node \FunctionLike
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ public function __construct(private Printer $printer)
2020
2121 public function printExpr (Expr $ expr ): string
2222 {
23+ // perf optimize for the most common path
24+ if ($ expr instanceof Expr \Variable && !$ expr ->name instanceof Expr) {
25+ return '$ ' . $ expr ->name ;
26+ }
27+
2328 /** @var string|null $exprString */
2429 $ exprString = $ expr ->getAttribute (self ::ATTRIBUTE_CACHE_KEY );
2530 if ($ exprString === null ) {
You can’t perform that action at this time.
0 commit comments