Skip to content

Commit 4c4e41d

Browse files
[VarDumper][HttpKernel] Enhance perf of ExceptionCaster & DataCollector
1 parent ba8ec57 commit 4c4e41d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

DataCollector/DataCollector.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
4242
*/
4343
private $cloner;
4444

45+
private static $stubsCache = array();
46+
4547
public function serialize()
4648
{
4749
return serialize($this->data);
@@ -124,14 +126,17 @@ private function decorateVar($var)
124126
return $var;
125127
}
126128
if (is_string($var)) {
129+
if (isset(self::$stubsCache[$var])) {
130+
return self::$stubsCache[$var];
131+
}
127132
if (false !== strpos($var, '\\')) {
128133
$c = (false !== $i = strpos($var, '::')) ? substr($var, 0, $i) : $var;
129134
if (class_exists($c, false) || interface_exists($c, false) || trait_exists($c, false)) {
130-
return new ClassStub($var);
135+
return self::$stubsCache[$var] = new ClassStub($var);
131136
}
132137
}
133138
if (false !== strpos($var, DIRECTORY_SEPARATOR) && false === strpos($var, '://') && false === strpos($var, "\0") && is_file($var)) {
134-
return new LinkStub($var);
139+
return self::$stubsCache[$var] = new LinkStub($var);
135140
}
136141
}
137142

0 commit comments

Comments
 (0)