This project is archived and is in readonly mode.
deprecate duplicable? and remove it from the framework
-
Michael Koziarski
rescues are quite expensive, this is why we added the duplicable thing in the first place ;)
Not sure what the right fix is here, what values have you seen this being called on?
-
Xavier Noria
My only concern is that the current code does not play by the rules for arbitrary values.
Deviating from standard Ruby approaches has to be very justified in my view. If experience shows the current approach works in practice, and that avoiding rescue in those points pays off in terms of performance, then no prob (I can't personally tell).
In that case I'd perhaps document the motivation in the rdoc of duplicable?.
-
Matt Jones
Looks like it's primarily used in ActiveRecord (2.3.4) in clone_attribute_value, which gets called by the dirty mechanism. So removing it in favor of rescue would impose additional execution cost on pretty much every attribute assignment that isn't duplicable (ie, integers and booleans).
-
Xavier Noria
Yes, and in a few more places (see the patch).
-
Xavier Noria
I did some isolated benchmarks and added this explanation in duplicable.rb:
http://github.com/lifo/docrails/commit/2ddbef421cb877bc219ac2737bbb...
Please feel free to close the ticket if the comment looks fine.
-
Xavier Noria
- State changed from new to wontfix
