Closed Bug 1487398 Opened 6 years ago Closed 6 years ago

Remove useless use of SetCapacity()

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

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().
(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.
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
See Also: → 1487612
Blocks: 1488142
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
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: