10000 collect called listeners information only once · symfony/symfony@fb59f8c · GitHub
[go: up one dir, main page]

Skip to content

Commit fb59f8c

Browse files
xabbuhfabpot
authored andcommitted
collect called listeners information only once
1 parent 8bdd25b commit fb59f8c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,22 +224,22 @@ public function getNotCalledListeners(/* Request $request = null */)
224224
}
225225

226226
$hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null;
227+
$calledListeners = [];
228+
229+
if (null !== $this->callStack) {
230+
foreach ($this->callStack as $calledListener) {
231+
list(, $requestHash) = $this->callStack->getInfo();
232+
233+
if (null === $hash || $hash === $requestHash) {
234+
$calledListeners[] = $calledListener->getWrappedListener();
235+
}
236+
}
237+
}
238+
227239
$notCalled = [];
228240
foreach ($allListeners as $eventName => $listeners) {
229241
foreach ($listeners as $listener) {
230-
$called = false;
231-
if (null !== $this->callStack) {
232-
foreach ($this->callStack as $calledListener) {
233-
list(, $requestHash) = $this->callStack->getInfo();
234-
if ((null === $hash || $hash === $requestHash) && $calledListener->getWrappedListener() === $listener) {
235-
$called = true;
236-
237-
break;
238-
}
239-
}
240-
}
241-
242-
if (!$called) {
242+
if (!\in_array($listener, $calledListeners, true)) {
243243
if (!$listener instanceof WrappedListener) {
244244
$listener = new WrappedListener($listener, null, $this->stopwatch, $this);
245245
}

0 commit comments

Comments
 (0)
0