Skip to content

Commit

Permalink
[Micro Optimization] Use slice instead of reverse->take (#3098)
Browse files Browse the repository at this point in the history
This does exactly the same but avoiding an array reverse
  • Loading branch information
Tofandel authored Nov 17, 2022
1 parent c86fb92 commit 9e34cb2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/MediaCollections/FileAdder.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ protected function processMediaItem(HasMedia $model, Media $media, self $fileAdd
$collectionMedia = $this->subject->fresh()->getMedia($media->collection_name);

if ($collectionMedia->count() > $collectionSizeLimit) {
$model->clearMediaCollectionExcept($media->collection_name, $collectionMedia->reverse()->take($collectionSizeLimit));
$model->clearMediaCollectionExcept($media->collection_name, $collectionMedia->slice(-$collectionSizeLimit, $collectionSizeLimit));
}
}
}
Expand Down

0 comments on commit 9e34cb2

Please sign in to comment.