Closed
Bug 1380549
Opened 7 years ago
Closed 7 years ago
nsStringBundle::FormatString seems to be doing an extra string copy for no reason
Categories
(Core :: XPCOM, enhancement)
Tracking
()
RESOLVED
FIXED
mozilla56
Tracking | Status | |
---|---|---|
firefox56 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
Attachments
(1 file)
2.27 KB,
patch
|
glandium
:
review+
|
Details | Diff | Splinter Review |
It's got a comment: // nsTextFormatter does not use the shared nsMemory allocator. // Instead it is required to free the memory it allocates using // nsTextFormatter::smprintf_free. Let's instead use nsMemory based // allocation for the result that we give out and free the string // returned by smprintf ourselves! *aResult = NS_strdup(text); nsTextFormatter::smprintf_free(text); But I'm fairly sure that at this point all the allocators involved are the same exact allocator, so this copy is pointless... Should probably wait for bug 1380227 to land before messing with this.
Flags: needinfo?(nfroyd)
Comment 1•7 years ago
|
||
Bug 1134923 removed NS_Alloc/NS_Realloc/NS_Free. There are leftovers because back then the standalone glue still mattered, but that's mostly gone as of bug 1332523. So we can actually remove those leftovers. Which then makes the whole point of NS_str*dup moot. I'd go as far as saying we should probably get rid of all the NS_str* functions, in favor of methods of the String classes (although those might actually be using the NS_str* functions under the hood at the moment).
Assignee | ||
Comment 2•7 years ago
|
||
We just have one allocator around now.
Attachment #8886641 -
Flags: review?(mh+mozilla)
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Assignee | ||
Updated•7 years ago
|
Flags: needinfo?(nfroyd)
Comment 3•7 years ago
|
||
Looks like smprintf_free() can be removed altogether, and its uses replaced with free()? It already has a comment deprecating it. And a similar story for JS_smprintf_free() and js_free(). That would just leave PR_smprintf_free(), which is a harder one to remove thanks to it being NSPR.
Updated•7 years ago
|
Attachment #8886641 -
Flags: review?(mh+mozilla) → review+
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/59532b5342bc Remove unnecessary strdup in stringbundle code. r=glandium
Assignee | ||
Comment 6•7 years ago
|
||
I filed bug 1381725, bug 1381726, and bug 1381727. Thank you all for the review and suggestions!
Comment 7•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/59532b5342bc
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox56:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in
before you can comment on or make changes to this bug.
Description
•