Open Bug 989835 Opened 10 years ago Updated 2 years ago

nsScriptableUnicodeConverter could avoid some string copies

Categories

(Core :: Internationalization, defect)

defect

Tracking

()

People

(Reporter: dbaron, Unassigned)

Details

(Keywords: perf)

From looking at the patch to bug 984379 in https://hg.mozilla.org/integration/mozilla-inbound/rev/c8ecf1ba4139 , it looks like the string copies that nsScriptableUnicodeConverter does in its nsAString output cases are avoidable.

In particular, it could use SetLength (with fallible_t()) and BeginWriting on the string instead of allocating a separate buffer and then copying that buffer to the string.

It would, however, require a bit of restructuring how the code is shared between the char** methods and the nsAString& methods (or, alternately, just sharing less code).

(I'm not planning to work on this, but I wanted to file a bug on it in case somebody else wanted to.)
(Note that using Adopt, per bug 984379 comment 4, is not quite as good as what I suggest here because what I suggest here allows the reference-counted buffer to be shared on assignment, whereas Adopt does not create a reference-counted buffer.)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.