8000 revert #30525 due to performance penalty · symfony/symfony@3d37cc9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d37cc9

Browse files
committed
revert #30525 due to performance penalty
1 parent 67af93f commit 3d37cc9

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ class PropertyInfoCacheExtractor implements PropertyInfoExtractorInterface, Prop
2424
{
2525
private $propertyInfoExtractor;
2626
private $cacheItemPool;
27-
28-
/**
29-
* A cache of property information, first keyed by the method called and
30-
* then by the serialized method arguments.
31-
*
32-
* @var array
33-
*/
3427
private $arrayCache = [];
3528

3629
public function __construct(PropertyInfoExtractorInterface $propertyInfoExtractor, CacheItemPoolInterface $cacheItemPool)
@@ -110,34 +103,22 @@ private function extract(string $method, array $arguments)
110103
}
111104

112105
// Calling rawurlencode escapes special characters not allowed in PSR-6's keys
113-
$encodedMethod = rawurlencode($method);
114-
if (\array_key_exists($encodedMethod, $this->arrayCache) && \array_key_exists($serializedArguments, $this->arrayCache[$encodedMethod])) {
115-
return $this->arrayCache[$encodedMethod][$serializedArguments];
106+
$key = rawurlencode($method.'.'.$serializedArguments);
107+
108+
if (\array_key_exists($key, $this->arrayCache)) {
109+
return $this->arrayCache[$key];
116110
}
117111

118-
$item = $this->cacheItemPool->getItem($encodedMethod);
112+
$item = $this->cacheItemPool->getItem($key);
119113

120-
$data = $item->get();
121114
if ($item->isHit()) {
122-
$this->arrayCache[$encodedMethod] = $data[$encodedMethod];
123-
// Only match if the specific arguments have been cached.
124-
if (\array_key_exists($serializedArguments, $data[$encodedMethod])) {
125-
return $this->arrayCache[$encodedMethod][$serializedArguments];
126-
}
127-
}
128-
129-
// It's possible that the method has been called, but with different
130-
// arguments, in which case $data will already be initialized.
131-
if (!$data) {
132-
$data = [];
115+
return $this->arrayCache[$key] = $item->get();
133116
}
134117

135118
$value = $this->propertyInfoExtractor->{$method}(...$arguments);
136-
$data[$encodedMethod][$serializedArguments] = $value;
137-
$this->arrayCache[$encodedMethod][$serializedArguments] = $value;
138-
$item->set($data);
119+
$item->set($value);
139120
$this->cacheItemPool->save($item);
140121

141-
return $this->arrayCache[$encodedMethod][$serializedArguments];
122+
return $this->arrayCache[$key] = $value;
142123
}
143124
}

0 commit comments

Comments
 (0)
0