Closed brianstien closed 8 years ago
:+1:
Regarding the performance of the typecasters, I feel that the best way to improve their performance is to skip them entirely for data coming from the data adapters. Since the data adapters often already handle typecasting, if the attribute storage mechanism allowed a way to write attributes without typecasting the data adapters could skip this code.
I simply brought over the existing active_attr typecasters in an attempt to make sure we are not introducing breaking changes in this release.
So with that in mind, I would prefer to leave the typecasters alone for now. I think with a bit of work the typecasters will be optimized out of reads entirely.
This removes the active_attr typecasting module and and implements our own. Instead of typecasting at the read time of an attribute (or attributes), this moves the typecasting to write time.
This is a substantial performance improvement whenever
attributes
, orrespond_to?
is called on an instance, we do not have to typecast every attribute.I imported the active_attr typecasters and also kept their same dsl so this is backwards compatible.
In the future I think the attribute store should allow attributes to be written without typecasting, so that we can skip that step when getting data from an adapter, which has likely already done the typecasting. Currently the attribute store is just a dumb hash, but I think that should be improved.