laravel/framework — pull request #1259 by KaneCohen (2013-05-10 10:24:47+00:00)
Title: Eloquent Collection dictionary refresh

This is not a PR, more of an issue.

Eloquent Collection has dictionary of models that is generated any time you try to use one of the method that deals with models by it's primary key. Problem is, once that dictionary is generated it'll stay the same no matter what you do with collection. You can remove half of the models, but still will be able to access removed models via `find(id)`.

In the code you can see that i'm comparing hash strings of cached items array and current items array. It's not the fastest solution (20ms on 1000 iterations loop - about ten times slower then current dictionary length check), so that got to be considered.

Maybe add second hash variable that is being generated every time items array is being mutated and just compare to hashes.