Simplify hb_utf_prev<16> to call hb_utf_next<16>

pull/46/head
Behdad Esfahbod 10 years ago
parent c09a607a84
commit 7323d385cc
  1. 23
      src/hb-utf-private.hh

@ -134,7 +134,8 @@ hb_utf_prev (const uint16_t *text,
const uint16_t *start,
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)))
{
@ -142,22 +143,14 @@ hb_utf_prev (const uint16_t *text,
return text;
}
if (likely (hb_in_range (c, 0xDC00u, 0xDFFFu)))
{
/* Low-surrogate in c */
hb_codepoint_t h;
if (start < text && ((h = *(text - 1)), likely (hb_in_range (h, 0xD800u, 0xDBFFu))))
{
/* High-surrogate in h */
*unicode = (h << 10) + c - ((0xD800u << 10) - 0x10000u + 0xDC00u);
text--;
return text;
}
}
if (likely (start < text && hb_in_range (c, 0xDC00u, 0xDFFFu)))
text--;
if (likely (hb_utf_next (text, end, unicode) == end))
return text;
/* Lonely / out-of-order surrogate. */
*unicode = -1;
return text;
return end - 1;
}

Loading…
Cancel
Save