Page 2 of 2
Re: SDL: Controlling input
Posted: Sat May 01, 2010 12:28 pm
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.
Re: SDL: Controlling input
Posted: Sat May 01, 2010 12:29 pm
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.
Re: SDL: Controlling input
Posted: Sat May 01, 2010 3:23 pm
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