Model.all should return a new collection each time.#118
Model.all should return a new collection each time.#118vaughankg wants to merge 2 commits intosxross:masterfrom
Conversation
|
This change makes me nervous. Using dup on a collection will, at a minimum, create a lot of garbage each time the |
|
Cool I'll look into it. |
|
Hey, I'm not sure exactly what you are after with regards to the garbage collection. Can you sketch it out for me? I've been exploring the code and these are a couple of observations: Calling x = Task.all
x.push("eggs")
Task.all #=> ["eggs"]I also think that Currently ArrayFinderQuery will (mostly) return a new collection object by way of calling the Task.all.object_id #=> 156194608
Task.where(:name).all.object_id #=> 156194608
Task.where(:name).contains('').all.object_id #=>155272720 <- different
Task.where{ true }.all.object_id #=> 152138352 <- different |
|
I'm not disputing your evaluation of the semantics of what Again, I'm not totally certain of this, but it seems unsafe to make this kind of change. Let's keep this discussion open and you think about it. It's an efficiency (memory/speed) versus semantic difference and in this case, we discovered that the efficiency made sense to pursue. If you want to check your branch, create an app that does what you propose using Thanks! |
|
Sounds good. I'll play with my |
Seems like x should be unchanged in the following example. What do you think?
Using the ArrayModelAdapter