looks good, but maybe this calculation better to move into some static inline function.
and better describe what this calculation does (all optimizations aspects)
or do it in upstream bug.