From 0f9a4e0470eb742458148075011702b23497183e Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 18 Sep 2008 03:40:28 +0000 Subject: [PATCH] Optimizing in_array() checks to isset(). No more in_array($a, array_keys($b)) patterns exist. Closes #5161 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7624 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/controller/components/request_handler.php | 4 ++-- cake/libs/xml.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index 520b4493e..10b6316b8 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -439,7 +439,7 @@ class RequestHandlerComponent extends Object { return false; } elseif (is_string($type)) { - if (!in_array($type, array_keys($this->__requestContent))) { + if (!isset($this->__requestContent[$type])) { return false; } @@ -560,7 +560,7 @@ class RequestHandlerComponent extends Object { $this->__renderType = $type; $controller->layoutPath = $type; - if (in_array($type, array_keys($this->__requestContent))) { + if (isset($this->__requestContent[$type])) { $this->respondAs($type, $options); } diff --git a/cake/libs/xml.php b/cake/libs/xml.php index bf226c1aa..c6680e742 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -1086,13 +1086,13 @@ class Xml extends XmlNode { */ function resolveNamespace($name, $url) { $_this =& XmlManager::getInstance(); - if ($url == null && in_array($name, array_keys($_this->defaultNamespaceMap))) { + if ($url == null && isset($_this->defaultNamespaceMap[$name])) { $url = $_this->defaultNamespaceMap[$name]; } elseif ($url == null) { return false; } - if (!strpos($url, '://') && in_array($name, array_keys($_this->defaultNamespaceMap))) { + if (!strpos($url, '://') && isset($_this->defaultNamespaceMap[$name])) { $_url = $_this->defaultNamespaceMap[$name]; $name = $url; $url = $_url; @@ -1117,7 +1117,7 @@ class Xml extends XmlNode { */ function removeGlobalNs($name) { $_this =& XmlManager::getInstance(); - if (in_array($name, array_keys($_this->namespaces))) { + if (isset($_this->namespaces[$name])) { unset($_this->namespaces[$name]); unset($this->namespaces[$name]); return true;