提交 44ae9be7 编写于 作者: K Konstantin Ritt

Nano optimization to hb_utf16_t and hb_utf32_t ::next()

上级 a6d7668a
...@@ -146,11 +146,11 @@ struct hb_utf16_t ...@@ -146,11 +146,11 @@ struct hb_utf16_t
return text; return text;
} }
if (likely (hb_in_range (c, 0xD800u, 0xDBFFu))) if (likely (c <= 0xDBFFu && text < end))
{ {
/* High-surrogate in c */ /* High-surrogate in c */
hb_codepoint_t l; hb_codepoint_t l = *text;
if (text < end && ((l = *text), likely (hb_in_range (l, 0xDC00u, 0xDFFFu)))) if (likely (hb_in_range (l, 0xDC00u, 0xDFFFu)))
{ {
/* Low-surrogate in l */ /* Low-surrogate in l */
*unicode = (c << 10) + l - ((0xD800u << 10) - 0x10000u + 0xDC00u); *unicode = (c << 10) + l - ((0xD800u << 10) - 0x10000u + 0xDC00u);
...@@ -211,14 +211,9 @@ struct hb_utf32_t ...@@ -211,14 +211,9 @@ struct hb_utf32_t
hb_codepoint_t *unicode, hb_codepoint_t *unicode,
hb_codepoint_t replacement) hb_codepoint_t replacement)
{ {
hb_codepoint_t c = *text++; hb_codepoint_t c = *unicode = *text++;
if (validate && unlikely (c > 0x10FFFFu || hb_in_range (c, 0xD800u, 0xDFFFu))) if (validate && unlikely (c >= 0xD800u && (c <= 0xDFFFu || c > 0x10FFFFu)))
goto error; *unicode = replacement;
*unicode = c;
return text;
error:
*unicode = replacement;
return text; return text;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册