Skip to content

Commit

Permalink
Some small performance optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 1, 2012
1 parent 6a9fdd8 commit 7d098fa
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/Cake/Utility/Hash.php
Expand Up @@ -256,25 +256,25 @@ protected static function _simpleOp($op, $data, $path, $values = null) {
$_list =& $data;

$count = count($path);
$last = $count - 1;
foreach ($path as $i => $key) {
if (is_numeric($key) && intval($key) > 0 || $key === '0') {
$key = intval($key);
}
if ($op === 'insert') {
if ($i === $count - 1 && is_array($_list)) {
if ($i === $last) {
$_list[$key] = $values;
} else {
if (!isset($_list[$key])) {
$_list[$key] = array();
}
$_list =& $_list[$key];
return $data;
}
if (!isset($_list[$key])) {
$_list[$key] = array();
}
$_list =& $_list[$key];
if (!is_array($_list)) {
$_list = array();
}
}
if ($op === 'remove') {
if ($i === count($path) - 1) {
} elseif ($op === 'remove') {
if ($i === $last) {
unset($_list[$key]);
} else {
if (!isset($_list[$key])) {
Expand Down

0 comments on commit 7d098fa

Please sign in to comment.