Reputation: 21657
if I have two integer variables with allocated memory and value a and b, which is the more time consuming (time of execution by the processor) operation: comparison (a == b)
or assignment (a = b)
? And why?
Upvotes: 1
Views: 1235
Reputation: 36349
Because the assignment involves a memory write (assuming that a is not a local value held in a register), chances are that it is slower on contemporary processors.
Upvotes: 0
Reputation: 1531
It probably depends on your processor architecture and the resulting binary executable.
Upvotes: 1