Skip to content

Commit

Permalink
Optimize BaseArrayHelper::isIndexed() (#19363)
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSilence authored Apr 24, 2022
1 parent 9eb268a commit a173488
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions framework/helpers/BaseArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,13 @@ public static function isIndexed($array, $consecutive = false)
return true;
}

$keys = array_keys($array);

if ($consecutive) {
return array_keys($array) === range(0, count($array) - 1);
return $keys === array_keys($keys);
}

foreach ($array as $key => $value) {
foreach ($keys as $key) {
if (!is_int($key)) {
return false;
}
Expand Down

0 comments on commit a173488

Please sign in to comment.