Ternary operator is twice as slow as an if-else block?
To answer this question, we’ll examine the assembly code produced by the X86 and X64 JITs for each of these cases. X86, if/then 32: foreach (int i in array) 0000007c 33 D2 xor edx,edx 0000007e 83 7E 04 00 cmp dword ptr [esi+4],0 00000082 7E 1C jle 000000A0 00000084 8B 44 96 08 mov eax,dword … Read more