Skip to content
Snippets Groups Projects
Verified Commit aaefc3f3 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2770065 by joseph.olstad, joelpittet, dawehner, catch, willzyx:...

Issue #2770065 by joseph.olstad, joelpittet, dawehner, catch, willzyx: array_key_exists() micro-optimization
parent f37dea08
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ class NestedArray {
public static function &getValue(array &$array, array $parents, &$key_exists = NULL) {
$ref = &$array;
foreach ($parents as $parent) {
if (is_array($ref) && array_key_exists($parent, $ref)) {
if (is_array($ref) && (isset($ref[$parent]) || array_key_exists($parent, $ref))) {
$ref = &$ref[$parent];
}
else {
......@@ -219,7 +219,7 @@ public static function setValue(array &$array, array $parents, $value, $force =
public static function unsetValue(array &$array, array $parents, &$key_existed = NULL) {
$unset_key = array_pop($parents);
$ref = &self::getValue($array, $parents, $key_existed);
if ($key_existed && is_array($ref) && array_key_exists($unset_key, $ref)) {
if ($key_existed && is_array($ref) && (isset($ref[$unset_key]) || array_key_exists($unset_key, $ref))) {
$key_existed = TRUE;
unset($ref[$unset_key]);
}
......
......@@ -96,7 +96,7 @@ public function has($key) {
// are not registered, just check the existence of the key in the registry.
// Use array_key_exists() here since a NULL value indicates that the theme
// hook exists but has not yet been requested.
return array_key_exists($key, $this->storage);
return isset($this->storage[$key]) || array_key_exists($key, $this->storage);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment