Skip to content

Commit d2518b9

Browse files
committed
Micro-optimize code to get first item of array
I finally chose to apply it as I think it is clearer.
1 parent 52d3a32 commit d2518b9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

system/Database/Query.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,14 @@ protected function compileBinds()
281281

282282
$binds = is_array($this->binds) ? $this->binds : [$this->binds];
283283

284-
if (is_int(key(array_slice($binds, 0, 1)))) {
284+
$array_is_list = null;
285+
286+
foreach ($binds as $key => $value) {
287+
$array_is_list = is_int($key);
288+
break;
289+
}
290+
291+
if ($array_is_list) {
285292
$bindCount = count($binds);
286293
$ml = strlen($this->bindMarker);
287294

0 commit comments

Comments
 (0)