@@ -31,11 +31,15 @@ class Resetter implements ResetterInterface
31
31
/** @var WeakMapSorter|null Note: We use temporal coupling here because of chicken/egg during bootstrapping */
32
32
private ?WeakMapSorter $ weakMapSorter = null ;
33
33
34
- /**
35
- * @var array
36
- */
34
+ /** @var array */
37
35
private array $ reflectionCache = [];
38
36
37
+ /** @var array */
38
+ private array $ isObjectInClassListCache = [];
39
+
40
+ /** @var array */
41
+ private readonly array $ classList ;
42
+
39
43
/**
40
44
* @param ComponentRegistrarInterface|null $componentRegistrar
41
45
* @param array $classList
@@ -44,7 +48,7 @@ class Resetter implements ResetterInterface
44
48
*/
45
49
public function __construct (
46
50
private ?ComponentRegistrarInterface $ componentRegistrar = null ,
47
- private array $ classList = [],
51
+ array $ classList = [],
48
52
) {
49
53
if (null === $ this ->componentRegistrar ) {
50
54
$ this ->componentRegistrar = new ComponentRegistrar ();
@@ -57,8 +61,9 @@ public function __construct(
57
61
if (!$ resetData ) {
58
62
throw new LocalizedException (__ ('Error parsing %1 ' , $ resetPath ));
59
63
}
60
- $ this -> classList += $ resetData ;
64
+ $ classList += $ resetData ;
61
65
}
66
+ $ this ->classList = $ classList ;
62
67
$ this ->resetAfterWeakMap = new WeakMap ;
63
68
}
64
69
@@ -138,11 +143,18 @@ public function setObjectManager(ObjectManagerInterface $objectManager) : void
138
143
*/
139
144
public function isObjectInClassList (object $ object )
140
145
{
146
+ $ className = \get_class ($ object );
147
+ $ isObjectInClassListCachedValue = $ this ->isObjectInClassListCache [$ className ] ?? null ;
148
+ if (null !== $ isObjectInClassListCachedValue ) {
149
+ return $ isObjectInClassListCachedValue ;
150
+ }
141
151
foreach ($ this ->classList as $ key => $ value ) {
142
152
if ($ object instanceof $ key ) {
153
+ $ this ->isObjectInClassListCache [$ className ] = true ;
143
154
return true ;
144
155
}
145
156
}
157
+ $ this ->isObjectInClassListCache [$ className ] = false ;
146
158
return false ;
147
159
}
148
160
0 commit comments