From a9378fb681df911bce7c20e699c361630236b51a Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 15 Mar 2008 05:04:36 +0000 Subject: [PATCH] Adding performance optimizations to dispatch cycle git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6570 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/dispatcher.php | 3 +-- cake/libs/controller/component.php | 6 ++++-- cake/libs/object.php | 28 +++++++--------------------- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index ac9600ad4..58a6c1e85 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -147,14 +147,13 @@ class Dispatcher extends Object { ) )); } - $missingAction = $missingView = $privateAction = false; if (empty($this->params['action'])) { $this->params['action'] = 'index'; } - $prefixes = Router::prefixes(); + if (!empty($prefixes)) { if (isset($this->params['prefix'])) { $this->params['action'] = $this->params['prefix'] . '_' . $this->params['action']; diff --git a/cake/libs/controller/component.php b/cake/libs/controller/component.php index 85fbed255..8ee3be0ce 100644 --- a/cake/libs/controller/component.php +++ b/cake/libs/controller/component.php @@ -100,7 +100,8 @@ class Component extends Object { 'className' => $this->controller->name, 'component' => $component, 'file' => Inflector::underscore($component) . '.php', - 'base' => $this->controller->base + 'base' => $this->controller->base, + 'code' => 500 ))); return false; } @@ -111,7 +112,8 @@ class Component extends Object { 'className' => $this->controller->name, 'component' => $component, 'file' => Inflector::underscore($component) . '.php', - 'base' => $this->controller->base + 'base' => $this->controller->base, + 'code' => 500 ))); return false; } diff --git a/cake/libs/object.php b/cake/libs/object.php index 28c68e94f..fc4d6c0df 100644 --- a/cake/libs/object.php +++ b/cake/libs/object.php @@ -103,27 +103,15 @@ class Object { * for call_user_func_array, and improves performance by using straight method calls * in most cases. * - * @param string $method Name of the method to call - * @param array $params Parameter list to use when calling $method - * @param boolean $strict If true, checks to make sure that $method is defined - * in this object. Throws a warning if not. - * @return mixed Returns the result of the method call, or null if $strict is - * true and the method was not found + * @param string $method Name of the method to call + * @param array $params Parameter list to use when calling $method + * @return mixed Returns the result of the method call * @access public */ - function dispatchMethod($method, $params = array(), $strict = false) { - if ($strict) { - if (!method_exists($this, $method)) { - trigger_error("Object::dispatchMethod() - Method {$method} not found in " . get_class($this), E_USER_WARNING); - return null; - } - } - if (empty($params)) { - return $this->{$method}(); - } - $params = array_values($params); - + function dispatchMethod($method, $params = array()) { switch (count($params)) { + case 0: + return $this->{$method}(); case 1: return $this->{$method}($params[0]); case 2: @@ -150,13 +138,11 @@ class Object { if (!class_exists('CakeLog')) { uses('cake_log'); } - if (is_null($this->_log)) { $this->_log = new CakeLog(); } - if (!is_string($msg)) { - $msg = print_r ($msg, true); + $msg = print_r($msg, true); } return $this->_log->write($type, $msg); }