Closed Bug 278835 Opened 20 years ago Closed 20 years ago

nsTextFormatter: cvt_s could use UTF8ToNewUnicode

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8beta2

People

(Reporter: Biesinger, Assigned: bzbarsky)

References

()

Details

(Keywords: memory-footprint)

Attachments

(1 file)

nsTextFormatter implements an UTF-8 to UTF-16 (or UCS-2, not sure) function itself. Instead, it could just use UTF8ToNewUnicode, provided by nsReadableUtils.
Attached patch How about this?Splinter Review
This even preserves the use of stack for not-too-big strings. The one drawback is that this doesn't return -1 on memory allocation failures... it just outputs an empty string. If that's deemed an issue, I can switch to using UTF8ToNewUnicode as suggested in the summary.
Attachment #173306 - Flags: superreview?(darin)
Attachment #173306 - Flags: review?(dougt)
I noticed this in the diff output: ** BiuldArgArray stands for Numbered Argument list Sprintf wanna fix that typo while touching code near it? :)
Yeah, I could do that.
Comment on attachment 173306 [details] [diff] [review] How about this? This looks great to me. sr=darin
Attachment #173306 - Flags: superreview?(darin) → superreview+
Comment on attachment 173306 [details] [diff] [review] How about this? r=dougt. Always love to remove code.
Attachment #173306 - Flags: review?(dougt) → review+
Assignee: dougt → bzbarsky
Target Milestone: --- → mozilla1.8beta2
Fixed on trunk for 1.8b2.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: