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
+8 -1
View File
@@ -61,11 +61,18 @@ class Context {
if (is_object($value)) { if (is_object($value)) {
return $value instanceof \Traversable; return $value instanceof \Traversable;
} elseif (is_array($value)) { } 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 true;
} else {
return false; return false;
} }
}
/** /**
* Push a new Context frame onto the stack. * Push a new Context frame onto the stack.