Closed Bug 317281 Opened 19 years ago Closed 19 years ago

Make UCS4 to High/Low surrogate a little bit more efficient

Categories

(Core :: XPCOM, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: jshin1987, Assigned: jshin1987)

Details

(Keywords: intl)

Attachments

(1 file)

Macros for UCS4 to high/low surrogate code points of UTF-16 in nsCharTrait.h can be made a bit more efficient.
Attached patch patchSplinter Review
This patch would save us a few cycles. Two formulae were circulated on the Unicode mailing list a few years ago and were used in our code (nsUTF32toUnicode.cpp)
Attachment #203791 - Flags: superreview?(bzbarsky)
Attachment #203791 - Flags: review?(smontagu)
Attachment #203791 - Flags: review?(smontagu) → review+
Comment on attachment 203791 [details] [diff] [review] patch >Index: xpcom/string/public/nsCharTraits.h >+// It's trivial to derive the following formulae from the Unicode standard >+// 4.0 section 3.7 I just looked at the standard, and isn't this actually section 3.9? >+// ((c - 0x10000) >> 10) + 0xd800 >+#define H_SURROGATE(c) PRUnichar(PRUnichar(PRUint32(c) >> 10) + \ >+ PRUnichar(0xD7C0)) Please document that this _MUST_ be '+' and not '|'. I'd be even happier with that _and_ a comment like: (c - 0x10000) >> 10 == (c >> 10) - 0x0080. And 0xD7C0 == 0xD800 - 0x0080. to make it clear what's going on. >+// ((c - 0x10000) & 0x03ff) | 0xdc00 And here, a comment like: (c - 0x10000) & 0x03FF == c & 0x03FF, since 0x10000 & 0x03FF == 0. With those comments, sr=bzbarsky
Attachment #203791 - Flags: superreview?(bzbarsky) → superreview+
thanks for quick reviews. I added comment lines suggested by bz
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: