Skip to content

Commit

Permalink
Inline Arr::pluck() in data_get() (#25938)
Browse files Browse the repository at this point in the history
- avoids "cross-calling" between these two methods
- 10~20% performance boost
  • Loading branch information
vlakoff authored and taylorotwell committed Oct 5, 2018
1 parent 385dc86 commit 2ab2fc6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Illuminate/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ function data_get($target, $key, $default = null)
return value($default);
}

$result = Arr::pluck($target, $key);
$result = [];

foreach ($target as $item) {
$result[] = data_get($item, $key);
}

return in_array('*', $key) ? Arr::collapse($result) : $result;
}
Expand Down

0 comments on commit 2ab2fc6

Please sign in to comment.