[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.
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.
- Re: Compiler could elide many more postblit constructor calls TommiT
- Re: Compiler could elide many more postblit constructor calls TommiT
