Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Optimization for Hash method

  • Loading branch information...
commit ecdf0e6c6cddd3108dae7abbe71bcba7d98a620a 1 parent 3e28326
@jrbasso jrbasso authored
Showing with 4 additions and 10 deletions.
  1. +4 −10 lib/Cake/Utility/Hash.php
View
14 lib/Cake/Utility/Hash.php
@@ -47,7 +47,7 @@ public static function get(array $data, $path) {
} else {
$parts = $path;
}
- while (($key = array_shift($parts)) !== null) {
+ foreach ($parts as $key) {
if (is_array($data) && isset($data[$key])) {
$data =& $data[$key];
} else {
@@ -106,8 +106,7 @@ public static function extract(array $data, $path) {
$context = array($_key => array($data));
- do {
- $token = array_shift($tokens);
+ foreach ($tokens as $token) {
$next = array();
$conditions = false;
@@ -137,7 +136,7 @@ public static function extract(array $data, $path) {
}
$context = array($_key => $next);
- } while (!empty($tokens));
+ }
return $context[$_key];
}
@@ -176,12 +175,7 @@ protected static function _matches(array $data, $selector) {
PREG_SET_ORDER
);
- $ok = true;
- while ($ok) {
- if (empty($conditions)) {
- break;
- }
- $cond = array_shift($conditions);
+ foreach ($conditions as $cond) {
$attr = $cond['attr'];
$op = isset($cond['op']) ? $cond['op'] : null;
$val = isset($cond['val']) ? $cond['val'] : null;

1 comment on commit ecdf0e6

@flotwig

Simply beautiful. :)

Please sign in to comment.
Something went wrong with that request. Please try again.