提交 7323d385 编写于 作者: B Behdad Esfahbod

Simplify hb_utf_prev<16> to call hb_utf_next<16>

上级 c09a607a
...@@ -134,7 +134,8 @@ hb_utf_prev (const uint16_t *text, ...@@ -134,7 +134,8 @@ hb_utf_prev (const uint16_t *text,
const uint16_t *start, const uint16_t *start,
hb_codepoint_t *unicode) hb_codepoint_t *unicode)
{ {
hb_codepoint_t c = *--text; const uint16_t *end = text--;
hb_codepoint_t c = *text;
if (likely (!hb_in_range (c, 0xD800u, 0xDFFFu))) if (likely (!hb_in_range (c, 0xD800u, 0xDFFFu)))
{ {
...@@ -142,22 +143,14 @@ hb_utf_prev (const uint16_t *text, ...@@ -142,22 +143,14 @@ hb_utf_prev (const uint16_t *text,
return text; return text;
} }
if (likely (hb_in_range (c, 0xDC00u, 0xDFFFu))) if (likely (start < text && hb_in_range (c, 0xDC00u, 0xDFFFu)))
{ text--;
/* Low-surrogate in c */
hb_codepoint_t h; if (likely (hb_utf_next (text, end, unicode) == end))
if (start < text && ((h = *(text - 1)), likely (hb_in_range (h, 0xD800u, 0xDBFFu)))) return text;
{
/* High-surrogate in h */
*unicode = (h << 10) + c - ((0xD800u << 10) - 0x10000u + 0xDC00u);
text--;
return text;
}
}
/* Lonely / out-of-order surrogate. */
*unicode = -1; *unicode = -1;
return text; return end - 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册