Time-consuming operation
if I have two integer variables with allocated memory and value a and b, which 开发者_StackOverflow中文版is the more time consuming (time of execution by the processor) operation: comparison (a == b)
or assignment (a = b)
? And why?
It probably depends on your processor architecture and the resulting binary executable.
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.
精彩评论