Skip to content

Commit 3ffb4fc

Browse files
committed
minor symfony#59164 [JsonEncoder] remove some unnecessary recomputations in LazyInstantiator (jdreesen)
This PR was merged into the 7.3 branch. Discussion ---------- [JsonEncoder] remove some unnecessary recomputations in LazyInstantiator | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | License | MIT The `$lazyClassName` is already set (and cached) in line 68. The `$path` is already created in line 80. Both don't need to be recalculated. Commits ------- a6f4524 [JsonEncoder] remove some unnecessary recomputations in LazyInstantiator
2 parents 2d54786 + a6f4524 commit 3ffb4fc

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Symfony/Component/JsonEncoder/Decode/LazyInstantiator.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* Instantiates a new $className lazy ghost {@see \Symfony\Component\VarExporter\LazyGhostTrait}.
2020
*
21-
* The $className class must not final.
21+
* The $className class must not be final.
2222
*
2323
* A property must be a callable that returns the actual value when being called.
2424
*
@@ -82,12 +82,10 @@ public function instantiate(string $className, array $propertiesCallables): obje
8282
$this->fs->mkdir($this->lazyGhostsDir);
8383
}
8484

85-
$lazyClassName = \sprintf('%sGhost', preg_replace('/\\\\/', '', $className));
86-
8785
file_put_contents($path, \sprintf('<?php class %s%s', $lazyClassName, ProxyHelper::generateLazyGhost($classReflection)));
8886
}
8987

90-
require_once \sprintf('%s%s%s.php', $this->lazyGhostsDir, \DIRECTORY_SEPARATOR, hash('xxh128', $className));
88+
require_once $path;
9189

9290
self::$lazyClassesLoaded[$className] = true;
9391

0 commit comments

Comments
 (0)