Perhaps an interesting observation about this is that while in C++ const correctness literally never improves performance [1], in D (if these optimizations were implemented) const correctness could potentially increase performance considerably (if there are expensive postblits). Thus, functions should take arguments by const value rather than value, when the type of the parameter is either templated or has postblit.

[1] Except with constant folding or when the compiler can put const data to rommable memory and then share it with multiple instances of the same program.

Reply via email to