Com­ing to an es­tab­lished work­flow for the first time is al­ways an
in­ter­est­ing ex­pe­ri­ence be­cause I don’t have any “it’s been like this since
for­ev­er” in­sights form­ing my opin­ion yet. This time it’s about quater­nion
in­ter­po­la­tion and a sud­den op­ti­miza­tion op­por­tu­ni­ty.

Large C++ projects of­ten suf­fer with very long times for both full
and in­cre­men­tal com­pi­la­tion, se­vere­ly hurt­ing pro­duc­tiv­i­ty. The fol­low­ing
se­ries will over­view some tech­niques em­ployed in Mag­num to make it­er­a­tion
times small­er, this ar­ti­cle fo­cus­es on code-based op­ti­miza­tions.

Thanks to gener­ic pro­gram­ming and oth­er fea­tures ex­clu­sive to C++ it
is pos­si­ble to han­dle poly­mor­phism the most ef­fec­tive way for each use
case. As a re­sult, vir­tu­al calls are in Mag­num used very spar­ing­ly.

While the pre­vi­ous part was fo­cused on C++11 fea­tures im­prov­ing
per­for­mance, here I will de­scribe fea­tures which are used just to sim­pli­fy
your life by writ­ing more con­cise code with less mis­takes.

Re­gard­less to what lan­guage you use, you al­ways need to think about
mem­o­ry man­age­ment. Garbage col­lec­tors might give you a sense that it’s done
au­tomag­i­cal­ly, but to get more per­for­mance you need to have con­trol over
heap us­age in code run­ning at 60 FPS. C++11 helps to avoid many heap
al­lo­ca­tions with­out sac­ri­fic­ing us­abil­i­ty.