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

Make pushing back to vectors more efficient #755

Merged
merged 5 commits into from
Nov 3, 2022

Conversation

AZero13
Copy link
Contributor

@AZero13 AZero13 commented Oct 21, 2022

In these places, emplace_back seems to be more efficient than push_back, and the better choice.

We can also improve performance further by reserving the size we know the vector will be so we do not have to waste time resizing.

@AZero13 AZero13 force-pushed the fix-3 branch 2 times, most recently from 0cd17b7 to caad698 Compare October 22, 2022 18:35
@AZero13 AZero13 changed the title Use emplace_back instead of push_back Make pushing back to vectors more efficient Oct 24, 2022
@JavierMatosD
Copy link
Contributor

JavierMatosD commented Oct 26, 2022

Hi @AtariDreams, thank you for the contributions. How did you determine what to refactor? Are you using a tool we could potentially use for our tests?

@AZero13
Copy link
Contributor Author

AZero13 commented Oct 27, 2022

Hi @AtariDreams, thank you for the contributions. How did you determine what to refactor? Are you using a tool we could potentially use for our tests?

clang-tidy checks for modernize-use-emplace.

@AZero13
Copy link
Contributor Author

AZero13 commented Oct 28, 2022

@BillyONeal fixed!

Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other occurrences aren't fixed

@AZero13
Copy link
Contributor Author

AZero13 commented Oct 30, 2022

@BillyONeal Done!

@AZero13 AZero13 force-pushed the fix-3 branch 4 times, most recently from a320310 to 978986d Compare November 2, 2022 15:06
@AZero13
Copy link
Contributor Author

AZero13 commented Nov 3, 2022

Any update on this?

AZero13 and others added 5 commits November 3, 2022 11:02
In these places, emplace_back seems to be more efficient than push_back, and the better choice.
It saves a lot of work reserving and working with references instead of copying directly
@BillyONeal
Copy link
Member

Thanks :)

@BillyONeal BillyONeal merged commit efd9e22 into microsoft:main Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants