Commit 7d9ae367 authored by Ad Schellevis's avatar Ad Schellevis

(config) performance improvement array_key_exists() vs isset()

parent 5bfa41fd
...@@ -102,7 +102,7 @@ class Config extends Singleton ...@@ -102,7 +102,7 @@ class Config extends Singleton
// copy attributes to @attribute key item // copy attributes to @attribute key item
foreach ($node->attributes() as $AttrKey => $AttrValue) { foreach ($node->attributes() as $AttrKey => $AttrValue) {
if (!array_key_exists('@attributes', $result)) { if (!isset($result['@attributes'])) {
$result['@attributes'] = array(); $result['@attributes'] = array();
} }
$result['@attributes'][$AttrKey] = $AttrValue->__toString(); $result['@attributes'][$AttrKey] = $AttrValue->__toString();
...@@ -112,7 +112,7 @@ class Config extends Singleton ...@@ -112,7 +112,7 @@ class Config extends Singleton
$xmlNodeName = $xmlNode->getName(); $xmlNodeName = $xmlNode->getName();
if ($xmlNode->count() > 0) { if ($xmlNode->count() > 0) {
$tmpNode = $this->toArray($forceList, $xmlNode); $tmpNode = $this->toArray($forceList, $xmlNode);
if (array_key_exists($xmlNodeName, $result)) { if (isset($result[$xmlNodeName])) {
$old_content = $result[$xmlNodeName]; $old_content = $result[$xmlNodeName];
// check if array content is associative, move items to new list // check if array content is associative, move items to new list
// (handles first item of specific type) // (handles first item of specific type)
...@@ -121,7 +121,7 @@ class Config extends Singleton ...@@ -121,7 +121,7 @@ class Config extends Singleton
$result[$xmlNodeName][] = $old_content; $result[$xmlNodeName][] = $old_content;
} }
$result[$xmlNodeName][] = $tmpNode; $result[$xmlNodeName][] = $tmpNode;
} elseif (is_array($forceList) && array_key_exists($xmlNodeName, $forceList)) { } elseif (isset($forceList[$xmlNodeName])) {
// force tag in an array // force tag in an array
$result[$xmlNodeName] = array(); $result[$xmlNodeName] = array();
$result[$xmlNodeName][] = $tmpNode; $result[$xmlNodeName][] = $tmpNode;
...@@ -129,7 +129,7 @@ class Config extends Singleton ...@@ -129,7 +129,7 @@ class Config extends Singleton
$result[$xmlNodeName] = $tmpNode; $result[$xmlNodeName] = $tmpNode;
} }
} else { } else {
if (array_key_exists($xmlNodeName, $result)) { if (isset($result[$xmlNodeName])) {
// repeating item // repeating item
if (!is_array($result[$xmlNodeName])) { if (!is_array($result[$xmlNodeName])) {
// move first item into list // move first item into list
...@@ -140,7 +140,7 @@ class Config extends Singleton ...@@ -140,7 +140,7 @@ class Config extends Singleton
$result[$xmlNodeName][] = $xmlNode->__toString(); $result[$xmlNodeName][] = $xmlNode->__toString();
} else { } else {
// single content item // single content item
if (is_array($forceList) && array_key_exists($xmlNodeName, $forceList)) { if (isset($forceList[$xmlNodeName])) {
$result[$xmlNodeName] = array(); $result[$xmlNodeName] = array();
if ($xmlNode->__toString() != null && trim($xmlNode->__toString()) !== "") { if ($xmlNode->__toString() != null && trim($xmlNode->__toString()) !== "") {
$result[$xmlNodeName][] = $xmlNode->__toString(); $result[$xmlNodeName][] = $xmlNode->__toString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment