You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Post-increments on iterators may be the reason of performance leaks. Also pre-increments are required by the Google styleguide.
Motivation
When a variable is incremented (++i or i++) or decremented (--i or i--) and the value of the expression is not used, one must decide whether to preincrement (decrement) or postincrement (decrement).
When the return value is ignored, the "pre" form (++i) is never less efficient than the "post" form (i++), and is often more efficient. This is because post-increment (or decrement) requires a copy of i to be made, which is the value of the expression. If i is an iterator or other non-scalar type, copying i could be expensive.
Proposed solution
The issue is about to change the all post-increment to pre-increment because it will save the memory and won't to copy the object.
The text was updated successfully, but these errors were encountered:
Introduction
Post-increments on iterators may be the reason of performance leaks. Also pre-increments are required by the Google styleguide.
Motivation
When a variable is incremented (++i or i++) or decremented (--i or i--) and the value of the expression is not used, one must decide whether to preincrement (decrement) or postincrement (decrement).
When the return value is ignored, the "pre" form (++i) is never less efficient than the "post" form (i++), and is often more efficient. This is because post-increment (or decrement) requires a copy of i to be made, which is the value of the expression. If i is an iterator or other non-scalar type, copying i could be expensive.
Proposed solution
The issue is about to change the all post-increment to pre-increment because it will save the memory and won't to copy the object.
The text was updated successfully, but these errors were encountered: