SDL: Controlling input

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: SDL: Controlling input

Post by qpHalcy0n »

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.
User avatar
Falco Girgis
Elysian Shadows Team
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

Post by Falco Girgis »

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.
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.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: SDL: Controlling input

Post by eatcomics »

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
Image
Post Reply