Handmade Hero»Forums»Code
David Roguin
15 posts
memory initialization in GUAR
Edited by David Roguin on
I've noticed that in the game update is always a check for memory initialization. I believe it's to simplify the platform code.

The question is: is that initialization going to be in another place for shipping? and save an IF in the game update?

Cheers!
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
memory initialization in GUAR
It'll probably stay there. It is a perfectly predicted branch (it's ALWAYS false every time after the first), so it's almost literally free in the context of the game code, so it's not worth making a separate function that has to get exposed to the platform layer.

Getting rid of "if" statements is more something you think about when you're inside a loop or recursion, where you know you are going to be executing hundreds or thousands of them.

- Casey
David Roguin
15 posts
memory initialization in GUAR
Thanks a lot!
5sw
Sven
31 posts
memory initialization in GUAR
Even though it might not cost anything at runtime, why would you want this initialization logic there?
David Roguin
15 posts
memory initialization in GUAR
It simplifies the creation of other platform implementations by only calling one function and it allows the hot reloading technique to be uber simple