While you're here, please stop saying these two things
quaternions avoid gimbal lock
premature optimization
why?
gimbal lock is related to a mechanism, quaternions are just an algebraic/geometric description of an angle-axis rotation. So they do not avoid it since the mechanism itself cannot.
if it's an optimization, if it's common sense, just implement it! Better do it now, than to look for it desperately later.