Closed
Bug 1487398
Opened 6 years ago
Closed 6 years ago
Remove useless use of SetCapacity()
Categories
(Core :: XPCOM, enhancement)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla64
Tracking | Status | |
---|---|---|
firefox64 | --- | fixed |
People
(Reporter: hsivonen, Assigned: hsivonen)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Remove various calls to SetCapacity() that fall into various misuse categories:
1) Mistakenly believing that the caller should advice the string about zero terminator.
2) Cases where appending does the right computation on its own.
3) Calling SetCapacity() with a constant when the string is self-allocated and could be an nsAuto[C]StringN.
4) Calling SetCapacity() before assigning a shared buffer to the string.
5) Calling SetCapacity() before calling a function that will either call SetLength() anyway or call Adopt().
Assignee | ||
Comment 1•6 years ago
|
||
(In reply to Henri Sivonen (:hsivonen) from comment #0)
> 3) Calling SetCapacity() with a constant when the string is self-allocated
> and could be an nsAuto[C]StringN.
...and used in such a way that the buffer isn't going to be shared with some future Assign target anyway.
Assignee | ||
Comment 2•6 years ago
|
||
Remove various calls to SetCapacity() that fall into various misuse categories:
1) Mistakenly believing that the caller should advice the string about zero
terminator.
2) Cases where a single append does the right computation on its own.
3) Calling SetCapacity() with a constant when the string is self-allocated
and could be an nsAuto[C]StringN and the string doesn't get passed on
in a way that could benefit from a heap-allocated buffer.
4) Calling SetCapacity() before assigning a shared buffer to the string.
5) Calling SetCapacity() before calling a function that will either calls
SetLength() anyway or calls Adopt().
MozReview-Commit-ID: IKjfl5gLmcD
Assignee | ||
Comment 3•6 years ago
|
||
![]() |
||
Comment 4•6 years ago
|
||
Comment on attachment 9005197 [details]
Bug 1487398 - Remove useless use of SetCapacity().
Nathan Froyd [:froydnj] has approved the revision.
Attachment #9005197 -
Flags: review+
Comment on attachment 9005197 [details]
Bug 1487398 - Remove useless use of SetCapacity().
Nicholas Hurley [:nwgh][:hurley] (he/him) has approved the revision.
Attachment #9005197 -
Flags: review+
Pushed by hsivonen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c67411f144d6
Remove useless use of SetCapacity(). r=froydnj,nwgh
Comment 7•6 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox64:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Updated•4 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•