Closed Bug 1448772 Opened 7 years ago Closed 7 years ago

Avoid back-and-forth UTF-16 to UTF-8 to UTF-16 conversions in xpcom/base/MacHelpers.mm

Categories

(Core :: Widget: Cocoa, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

Attachments

(1 file)

xpcom/base/MacHelpers.mm appears to ask an NSString (UTF-16) to provide a UTF-8 conversion and then immediately converts the result back to UTF-16. We should instead ask the NSString for its (UTF-16) length, resize the nsAString to that length and ask the NSString to write its contents to aCountryCode.BeginWriting(). (Not that converting a couple of characters matters much perf-wise, but I'm changing the signature of AppendUTF8toUTF16 so *some* change to these lines is going to be needed anyway.)
Trying to write a patch without a Mac...
Assignee: nobody → hsivonen
Status: NEW → ASSIGNED
Looks like neither bug 346345 nor bug 334670 ever got fixed. :-(
Comment on attachment 8962265 [details] Bug 1448772 - Avoid back-and-forth UTF-16 to UTF-8 to UTF-16 conversions in xpcom/base/MacHelpers.mm. https://reviewboard.mozilla.org/r/231126/#review238420 Looks good, thank you! ::: toolkit/crashreporter/mac_utils.mm:22 (Diff revision 14) > - [name getCharacters:nameBuffer]; > - [reason getCharacters:reasonBuffer]; > + (void) mozilla::CopyCocoaStringToXPCOMString(name, nameStr); > + (void) mozilla::CopyCocoaStringToXPCOMString(reason, reasonStr); You could also use mozilla::unused << here.
Attachment #8962265 - Flags: review?(mstange) → review+
Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/24f434072ecd Avoid back-and-forth UTF-16 to UTF-8 to UTF-16 conversions in xpcom/base/MacHelpers.mm. r=mstange
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: