Re:Which is faster? while(1) {} or while(2) {}
by zokier on Monday July 21, 2014 @09:30AM
(#8063549)
You are very close to making the same mistake as the interviewer did. The compiled program will not have any tests or casts or anything like that, because the condition is known at compile-time and the compiler just compiles it down to an unconditional jump.
[ Parent
| on HN ]
Re:Which is faster? while(1) {} or while(2) {}
by goldenkey on Monday July 21, 2014 @10:22AM
(#8063776)
I'm not making any mistakes. It wouldn't even be a jump at all, just static code if the statement was compile time optimized. I failed to mention it because it's trivial enough without the extra fluff of compile time magic