Skip to content

Commit d6ecb78

Browse files
Avoid unnecessary filtering when no callback is provided (#56225)
1 parent 8a98908 commit d6ecb78

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Illuminate/Http/Client/Factory.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,12 +469,13 @@ public function recorded($callback = null)
469469
return new Collection;
470470
}
471471

472-
$callback = $callback ?: function () {
473-
return true;
474-
};
472+
$collect = new Collection($this->recorded);
473+
474+
if ($callback) {
475+
return $collect->filter(fn ($pair) => $callback($pair[0], $pair[1]));
476+
}
475477

476-
return (new Collection($this->recorded))
477-
->filter(fn ($pair) => $callback($pair[0], $pair[1]));
478+
return $collect;
478479
}
479480

480481
/**

0 commit comments

Comments
 (0)