Closed Bug 1041140 Opened 6 years ago Closed 6 years ago

FakeString is badly designed

Categories

(Core :: DOM: Core & HTML, defect)

33 Branch
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: neil, Assigned: neil)

References

Details

(Keywords: memory-footprint, perf, regression)

Attachments

(1 file)

FakeString requires you to call SetCapacity(n + 1), SetLength(n), and then BeginWriting()[n] = char16_t(0). A real string does all this in one call to SetLength(n), and the calls to SetCapacity(n + 1) that are made on real strings could allocate more than necessary.
Attached patch Proposed patchSplinter Review
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #8459150 - Flags: review?(bzbarsky)
Comment on attachment 8459150 [details] [diff] [review]
Proposed patch

>+    if (aLength < sInlineCapacity) {
>       SetData(mInlineStorage);
>     }
>+    else {

else goes up next to the '}'.

r=me with that, though this change will make bug 1025183 a bit more painful....
Attachment #8459150 - Flags: review?(bzbarsky) → review+
Thanks Neil! It was on my list (needinfo) but I didn't get to it yet.
https://hg.mozilla.org/mozilla-central/rev/9350909a3401
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.