TransferBoy icon indicating copy to clipboard operation
TransferBoy copied to clipboard

Use global rootState instead of passing it around.

Open joeldipops opened this issue 5 years ago • 1 comments

"In C globals are more common especially in the era when RAM was limited. So it's not "bad" it's normal. Modern Object Oriented code would pass variables around from function to function and would feel clean but use more RAM and spend more time copying data from place to place."

joeldipops avatar Jan 01 '20 01:01 joeldipops

Have done this for all references to RootState, and it's neither sped up nor slowed down performance significantly. There may be additional scope to this - places where I pass around a playerState reference when I might be better just passing a player number int.

Though either way you're still passing something so it might not make a difference. Hrmm. Worth a try I guess.

joeldipops avatar Jan 01 '20 01:01 joeldipops