Skip to content
Permalink
Browse files

Improved Hash::get() performance

Calling Hash::get() with just one key is a very rare, since you can do $data[$key] directly. Just by adding this check it decreases the performance in about 15%.
  • Loading branch information...
jrbasso committed Sep 7, 2014
1 parent 618eaa0 commit cc14f4bb646f3b35c8ad3846abd1e3dedecd6aaf
Showing with 1 addition and 7 deletions.
  1. +1 −7 src/Utility/Hash.php
@@ -44,13 +44,7 @@ public static function get(array $data, $path, $default = null) {
return $default;
}
$isString = is_string($path);
if ($isString && strpos($path, '.') === false) {
return isset($data[$path]) ? $data[$path] : $default;
}
if ($isString || is_numeric($path)) {
if (is_string($path) || is_numeric($path)) {
$parts = explode('.', $path);
} else {
if (!is_array($path)) {

0 comments on commit cc14f4b

Please sign in to comment.
You can’t perform that action at this time.