Profiles and optimised EventManager::listeners() function, reducing execution time by 14.5%

Refs #2105
This commit is contained in:
Andy Hobbs 2013-09-13 09:56:38 +01:00 committed by mark_story
parent 3561929be7
commit e8984a9033

View file

@ -267,7 +267,18 @@ class CakeEventManager {
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);