Change atoms to vars in gungnir.model
kwrooijen opened this issue · 2 comments
Currently the model namespace keeps track of registered models and creates maps for "quick" mapping (e.g. mapping a model field to table column). This is mainly for performance benefits.
gungnir/src/cljc/gungnir/model.cljc
Lines 12 to 17 in 54fa3b8
These maps are stored in atoms. However it might be nice to actually store then in ^:dynamic
defs and change them with alter-var!
. This would remove the deref overhead and possibly improve performance slightly. I don't think there's much risk in changing these to defs since they are only set during model registration. Which generally only happens once at system startup.
I don't think there's much risk in changing these to defs since they are only set during model registration. Which generally only happens once at system startup.
I think it is part of normal workflow to re- mode/register!
in the repl when working out the kinks in a model. Will that still be supported?
I don't see why not. The point of atoms is to handle parallelism and make sure data stays in sync. I can't imagine having two threads calling model/register!
at the same time. Other than that the current behavior will not change.