Skip to content

Commit

Permalink
Profiles and optimised EventManager::listeners() function, reducing e…
Browse files Browse the repository at this point in the history
…xecution time by 14.5%

Refs #2105
  • Loading branch information
Andy Hobbs authored and markstory committed Nov 11, 2013
1 parent 3561929 commit e8984a9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/Cake/Event/CakeEventManager.php
Expand Up @@ -267,7 +267,18 @@ public function listeners($eventKey) {
if (empty($this->_listeners[$eventKey])) {
return array();
}
ksort($this->_listeners[$eventKey]);

$listeners = $this->_listeners[$eventKey];
foreach ($globalListeners as $priority => $priorityQ) {
if (!empty($listeners[$priority])) {
$listeners[$priority] = array_merge($listeners[$priority], $priorityQ);
unset($globalListeners[$priority]);
}

$listeners = $listeners + $globalListeners;
}

ksort($listeners);
$result = array();
foreach ($this->_listeners[$eventKey] as $priorityQ) {
$result = array_merge($result, $priorityQ);
Expand Down

0 comments on commit e8984a9

Please sign in to comment.