3 ms·
Ha, I got asked this question during an interview many years ago. I knew the answer, but then the interviewer asked me why do they use this code (swap variables
by billconan 8y ago
Ha, I got asked this question during an interview many years ago. I knew the answer, but then the interviewer asked me why do they use this code (swap variables without a temp) in real code. (I was interviewing with device driver team) . I couldn't answer this one.
the reason is that if we only use operators without memory operations, the cpu pipeline can finish sooner, because the alu comes first in the pipeline. So it will be faster.