Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Profiles and optimised EventManager::listeners() function, reducing e…

…xecution time by 14.5%

Refs #2105
  • Loading branch information...
commit e8984a90331ed926753dc881fffe2e051c5704e1 1 parent 3561929
Andy Hobbs authored markstory committed
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/Cake/Event/CakeEventManager.php
View
13 lib/Cake/Event/CakeEventManager.php
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.