-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Enable performance-inefficient-vector-operation #48480
Merged
ZhilkinSerg
merged 2 commits into
CleverRaven:0.F-dev
from
jbytheway:clang-tidy_performance-inefficient-vector-operation
Apr 13, 2021
Merged
Enable performance-inefficient-vector-operation #48480
ZhilkinSerg
merged 2 commits into
CleverRaven:0.F-dev
from
jbytheway:clang-tidy_performance-inefficient-vector-operation
Apr 13, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
All changes done automatically by clang-tidy.
6051d99
to
2697c69
Compare
ZhilkinSerg
pushed a commit
that referenced
this pull request
Apr 20, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
Apr 20, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
Apr 20, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
May 28, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
May 28, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
May 31, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
Jun 14, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
Jun 14, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
Jun 14, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
Jun 21, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
ZhilkinSerg
pushed a commit
that referenced
this pull request
Jul 3, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
anothersimulacrum
pushed a commit
to anothersimulacrum/Cataclysm-DDA
that referenced
this pull request
Jul 3, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
KorGgenT
pushed a commit
to KorGgenT/Cataclysm-DDA
that referenced
this pull request
Jul 4, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
Maleclypse
pushed a commit
to Maleclypse/Cataclysm-DDA
that referenced
this pull request
Jul 4, 2021
* Add a collection of `vector::reserve` calls. All changes done automatically by clang-tidy. * Enable performance-inefficient-vector-operation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[C++]
Changes (can be) made in C++. Previously named `Code`
Code: Infrastructure / Style / Static Analysis
Code internal infrastructure and style
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
None
Purpose of change
More static analysis.
This check looks for simple opportunities to use
vector::reserve
before a loop which pushes a known number of things to avector
. This is a simple performance optimization which can be quite beneficial in hot parts of the code by replacing O(log(n)) allocations by a single allocation (and reducing copying).Describe the solution
Enable the check and run
clang-tidy
. All changes were done automatically byclang-tidy
FIXITs.Describe alternatives you've considered
None.
Testing
Unit tests.
Additional context
Probably none of the specific changes in this PR matter for performance, because any places that did matter have probably already had a
reserve
call added. But by enabling this check we help ensure that new code doesn't miss out on this simple optimization.