Assuming that prefix and postfix operations perform the same computation,++i is generally more efficient than i++ in terms of cost.
Since i++ requires storing the original value in a temporary register, ++i is slightly cheaper.
++i
add rax, 1 ; i = i + 1
i++
mov rcx, rax ; old = i (temporary value)
add rax, 1 ; i = i + 1 (original value)'Programming Language > cpp' 카테고리의 다른 글
| mergeSort (0) | 2025.10.13 |
|---|---|
| std::array vs std::vector (0) | 2025.10.10 |