Skip to content

Commit 92d36bc

Browse files
committed
improved class reflection performance
1 parent a64c2d3 commit 92d36bc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/core/src/Kernel/LoadDiscoveryClasses.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
final class LoadDiscoveryClasses
2323
{
2424
private array $appliedDiscovery = [];
25+
private array $shouldSkipForClass = [];
2526

2627
public function __construct(
2728
private readonly Kernel $kernel,
@@ -228,13 +229,18 @@ private function shouldSkipBasedOnConfig(ClassReflector|string $input): bool
228229
*/
229230
private function shouldSkipDiscoveryForClass(Discovery $discovery, ClassReflector $input): bool
230231
{
231-
$attribute = $input->getAttribute(SkipDiscovery::class);
232+
if (! isset($this->shouldSkipForClass[$input->getName()])) {
233+
$attribute = $input->getAttribute(SkipDiscovery::class);
234+
235+
if ($attribute === null) {
236+
return false;
237+
}
238+
239+
$this->shouldSkipForClass[$input->getName()] = $attribute->except;
232240

233-
if ($attribute === null) {
234-
return false;
235241
}
236242

237-
return ! in_array($discovery::class, $attribute->except, strict: true);
243+
return ! in_array($discovery::class, $this->shouldSkipForClass[$input->getName()], strict: true);
238244
}
239245

240246
/**

0 commit comments

Comments
 (0)