3 ms·
I do so to enforce a single return value from functions. Given: static void damage(const Hero* hero, const Sprite* sprite); The const can easily dropped
by glouwbug 9y ago
I do so to enforce a single return value from functions.
Given:
static void damage(const Hero* hero, const Sprite* sprite);
The const can easily dropped later in production from both entities, potentionally creating two return values.
This is analougous to good use of privacy in C++ classes.
hero = spin(hero, key);
Becomes:
hero.spin(key);
Where external objects dictate the private state of the hero object.
Pointer aliasing is another thing. Inlining is easier with fewer pointers. A fun C++ experiment is to count your instruction and data cache points with valgrind's cachegrind with pod types both passed by value and by reference (&).