Skip to content

Commit

Permalink
[VarDumper] Improve performance of AbstractCloner
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz authored and nicolas-grekas committed Jan 25, 2019
1 parent edc4a0f commit cff23e5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class AbstractCloner implements ClonerInterface
'DOMProcessingInstruction' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castProcessingInstruction'],
'DOMXPath' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castXPath'],

'XmlReader' => ['Symfony\Component\VarDumper\Caster\XmlReaderCaster', 'castXmlReader'],
'XMLReader' => ['Symfony\Component\VarDumper\Caster\XmlReaderCaster', 'castXmlReader'],

'ErrorException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castErrorException'],
'Exception' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castException'],
Expand Down Expand Up @@ -177,7 +177,7 @@ public function __construct(array $casters = null)
public function addCasters(array $casters)
{
foreach ($casters as $type => $callback) {
$closure = &$this->casters['' === $type || ':' === $type[0] ? $type : strtolower($type)][];
$closure = &$this->casters[$type][];
$closure = $callback instanceof \Closure ? $callback : static function (...$args) use ($callback, &$closure) {
return ($closure = \Closure::fromCallable($callback))(...$args);
};
Expand Down Expand Up @@ -282,15 +282,15 @@ protected function castObject(Stub $stub, $isNested)
list($i, $parents, $hasDebugInfo) = $this->classInfo[$class];
} else {
$i = 2;
$parents = [strtolower($class)];
$parents = [$class];
$hasDebugInfo = method_exists($class, '__debugInfo');

foreach (class_parents($class) as $p) {
$parents[] = strtolower($p);
$parents[] = $p;
++$i;
}
foreach (class_implements($class) as $p) {
$parents[] = strtolower($p);
$parents[] = $p;
++$i;
}
$parents[] = '*';
Expand Down

0 comments on commit cff23e5

Please sign in to comment.