Check if array is iterable without full key diff.

~0.5-1% performance gain.
This commit is contained in:
Justin Hileman
2012-03-13 20:45:26 -07:00
parent 9a334cddf0
commit e09bfb502f
+10 -3
View File
@@ -61,10 +61,17 @@ class Context {
if (is_object($value)) {
return $value instanceof \Traversable;
} elseif (is_array($value)) {
return !array_diff_key($value, array_keys(array_keys($value)));
}
$i = 0;
foreach ($value as $k => $v) {
if ($k !== $i++) {
return false;
}
}
return false;
return true;
} else {
return false;
}
}
/**