@@ -605,19 +605,16 @@ protected static function combineCommonParents(array &$parents): void
605
605
}
606
606
}
607
607
608
- /**
609
- * @param array<PredictionContext|null> $visited
610
- */
611
608
public static function getCachedPredictionContext (
612
609
PredictionContext $ context ,
613
610
PredictionContextCache $ contextCache ,
614
- array &$ visited ,
611
+ IdentityHashMap &$ visited ,
615
612
): self {
616
613
if ($ context ->isEmpty ()) {
617
614
return $ context ;
618
615
}
619
616
620
- $ existing = $ visited[ \spl_object_id ($ context )] ?? null ;
617
+ $ existing = $ visited-> get ($ context );
621
618
622
619
if ($ existing !== null ) {
623
620
return $ existing ;
@@ -626,7 +623,7 @@ public static function getCachedPredictionContext(
626
623
$ existing = $ contextCache ->get ($ context );
627
624
628
625
if ($ existing !== null ) {
629
- $ visited[ \spl_object_id ($ context)] = $ existing ;
626
+ $ visited-> put ($ context, $ existing) ;
630
627
631
628
return $ existing ;
632
629
}
@@ -660,7 +657,7 @@ public static function getCachedPredictionContext(
660
657
if (!$ changed ) {
661
658
$ contextCache ->add ($ context );
662
659
663
- $ visited[ \spl_object_id ($ context)] = $ context ;
660
+ $ visited-> put ($ context, $ context) ;
664
661
665
662
return $ context ;
666
663
}
@@ -680,8 +677,8 @@ public static function getCachedPredictionContext(
680
677
}
681
678
682
679
$ contextCache ->add ($ updated );
683
- $ visited[ \spl_object_id ($ updated)] = $ updated ;
684
- $ visited[ \spl_object_id ($ context)] = $ updated ;
680
+ $ visited-> put ($ updated, $ updated) ;
681
+ $ visited-> put ($ context, $ updated) ;
685
682
686
683
return $ updated ;
687
684
}
0 commit comments