Given most compilers, if you actually look, it USUALLY generates the exact same code.
If the switch is pretty tightly packed and sequential, then the compiler MAY create a jump table which ends up being a smidge faster. What one compiler does another may not.
SDL: Controlling input
Moderator: Coders of Rage
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: SDL: Controlling input
Yeah, I was actually thinking that it could create a jump table out of it. I haven't actually looked at compiled if vs switch code, though.qpHalcy0n wrote:Given most compilers, if you actually look, it USUALLY generates the exact same code.
If the switch is pretty tightly packed and sequential, then the compiler MAY create a jump table which ends up being a smidge faster. What one compiler does another may not.
Re: SDL: Controlling input
Oh well then... Cool, I was just told by someone that switches were slower... Hm... Good thing I'm using switches in my code
Thank you guys for clearing that up
Thank you guys for clearing that up