We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loop is much slower then Value assigning. Debug with Disassemmbler on, and see the difference. Disassemble it, and see, that :
Value assiging is 1 or 3 CPU cycles ( depends, is variable in CPU register or in memory. Local variables are usually in CPU register, and it tooks 1 CPU cycle to assign)
Loop is 6 to 20+ CPU cycles - depnds, is it simple while, which actually internal is IF and JUMP operands, or it's a FOR, or even slower FOREACH
Still, there is one small issue with SALCIO's code.
if(index++>positionFromTail)result=result->next;
index++ (increment) is unneeded, after once index is bigger then positionFromTail. Though increment with ++ is only 1 CPU cycle ( INC operator), i with do it like:
Get Node Value
You are viewing a single comment's thread. Return to all comments →
Loop is much slower then Value assigning. Debug with Disassemmbler on, and see the difference. Disassemble it, and see, that :
Loop is 6 to 20+ CPU cycles - depnds, is it simple while, which actually internal is IF and JUMP operands, or it's a FOR, or even slower FOREACH
So,
is much, much faster then
Still, there is one small issue with SALCIO's code.
index++ (increment) is unneeded, after once index is bigger then positionFromTail. Though increment with ++ is only 1 CPU cycle ( INC operator), i with do it like: