Closed
Bug 1387376
Opened 8 years ago
Closed 8 years ago
Reserve memory before using push_back with vector
Categories
(Developer Infrastructure :: Source Code Analysis, enhancement)
Developer Infrastructure
Source Code Analysis
Tracking
(firefox57 fixed)
RESOLVED
FIXED
mozilla57
Tracking | Status | |
---|---|---|
firefox57 | --- | fixed |
People
(Reporter: Sylvestre, Assigned: Sylvestre)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
Assignee | ||
Updated•8 years ago
|
Summary: Reserve memory before using push_back in vector → Reserve memory before using push_back with vector
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 3•8 years ago
|
||
mozreview-review |
Comment on attachment 8893723 [details]
Bug 1387376 - Reserve memory before using push_back with vector
https://reviewboard.mozilla.org/r/164838/#review170392
::: media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp:559
(Diff revision 1)
> std::vector<std::string> attrs;
> + attrs.reserve(aCandidateList.size());
> for (const auto& candidate : aCandidateList) {
> attrs.push_back("candidate:" + candidate);
> }
> attrs.push_back("ice-ufrag:" + aUfrag);
> attrs.push_back("ice-pwd:" + aPassword);
Should be size() + 2 (see following lines). r+ with that change
Attachment #8893723 -
Flags: review?(rjesup) → review+
Comment hidden (mozreview-request) |
Comment 5•8 years ago
|
||
mozreview-review |
Comment on attachment 8893722 [details]
Bug 1387376 - Reserve memory before using push_back with vector
https://reviewboard.mozilla.org/r/164836/#review170702
It isn't useful to do this in gtests. This code isn't built into firefox and the change will not affect the time we spend running the tests. I don't really care either way. If this is reported by some static analysis and doing this removes noise from the analysis output, then why not. Otherwise, you don't need to bother with fine tuning the performance of loops that are only ever run once in gtests.
Attachment #8893722 -
Flags: review?(nical.bugzilla) → review+
Assignee | ||
Comment 6•8 years ago
|
||
mozreview-review-reply |
Comment on attachment 8893722 [details]
Bug 1387376 - Reserve memory before using push_back with vector
https://reviewboard.mozilla.org/r/164836/#review170702
Yeah, this is just to make clang-tidy happy and not bother with ignoring that warning.
Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d0352fcfda33
Reserve memory before using push_back with vector r=nical
https://hg.mozilla.org/integration/autoland/rev/f35d46bca9a9
Reserve memory before using push_back with vector r=jesup
Comment 8•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d0352fcfda33
https://hg.mozilla.org/mozilla-central/rev/f35d46bca9a9
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Updated•7 years ago
|
Product: Core → Firefox Build System
Updated•3 years ago
|
Product: Firefox Build System → Developer Infrastructure
You need to log in
before you can comment on or make changes to this bug.
Description
•