8000 merged branch drak/eventdispatcher_opimization (PR #2597) · barros001/symfony@db6fea9 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit db6fea9

Browse files
committed
merged branch drak/eventdispatcher_opimization (PR symfony#2597)
Commits ------- 0fe8ac6 [EventDispatcher] Removed unused argument. Discussion ---------- [EventDispatcher] Removed unused parameter in doDispatch(). Bug fix: no Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: - Removed unused parameter. --------------------------------------------------------------------------- by Seldaek at 2011/11/10 02:30:01 -0800 A simple $foo($arg) is faster than call_user_func, fine, but with all the if/else logic here are you sure it is still faster? --------------------------------------------------------------------------- by drak at 2011/11/10 06:44:41 -0800 call_user_func is inordinately slow, I'll make some benchmarks. The if logic here is pretty, two conditionals for array callables or one conditional for closures/functions. --------------------------------------------------------------------------- by drak at 2011/11/10 12:45:27 -0800 After doing some benchmarks, there are savings to be made in all cases except when the listener is an instantiated object when it's marginally slower, so I've reverted these changes and made this PR just to remove the unused argument in `doDispatch()`. You can see the benchmark code here: https://gist.github.com/1356129. --------------------------------------------------------------------------- by drak at 2011/11/10 12:46:55 -0800 This PR is ready for consideration.
2 parents 47b09f7 + 0fe8ac6 commit db6fea9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Symfony/Component/EventDispatcher/EventDispatcher.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function dispatch($eventName, Event $event = null)
4747
$event = new Event();
4848
}
4949

50-
$this->doDispatch($this->getListeners($eventName), $eventName, $event);
50+
$this->doDispatch($this->getListeners($eventName), $event);
5151
}
5252

5353
/**
@@ -150,10 +150,9 @@ public function removeSubscriber(EventSubscriberInterface $subscriber)
150150
* for each listener.
151151
*
152152
* @param array[callback] $listeners The event listeners.
153-
* @param string $eventName The name of the event to dispatch.
154153
* @param Event $event The event object to pass to the event handlers/listeners.
155154
*/
156-
protected function doDispatch($listeners, $eventName, Event $event)
155+
protected function doDispatch($listeners, Event $event)
157156
{
158157
foreach ($listeners as $listener) {
159158
call_user_func($listener, $event);

0 commit comments

Comments
 (0)
0