Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change post-increments to pre-increments #2314

Closed
ghost opened this issue Jul 2, 2018 · 1 comment
Closed

Change post-increments to pre-increments #2314

ghost opened this issue Jul 2, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 2, 2018

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.

@ghost ghost added the proposal Accepted SDL Evolution Proposal label Jul 2, 2018
@AStasiuk AStasiuk removed the proposal Accepted SDL Evolution Proposal label Jul 2, 2018
@iCollin
Copy link
Collaborator

iCollin commented Apr 20, 2021

Closed via #3687

@iCollin iCollin closed this as completed Apr 20, 2021
@iCollin iCollin added this to Completed Bug Fixes/ Enhancements in 8.0.0 Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
8.0.0
Completed Bug Fixes / Enhancements
Development

No branches or pull requests

3 participants