[HarfBuzz] harfbuzz: Branch 'master' - 3 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sat Nov 7 07:52:06 PST 2015
src/hb-utf-private.hh | 46 +++++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 21 deletions(-)
New commits:
commit d5f0d7c9fb14255388ab616f56e178cb7ca10ec2
Merge: 04ff23e 529a933
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Nov 7 07:50:58 2015 -0800
Merge pull request #167 from KonstantinRitt/unicode_cp_opt
Micro optimizations to UTF-16 and UTF-32 codecs
commit 529a93312815dff3c2f37f880bf6ccb428bd3da0
Author: Konstantin Ritt <ritt.ks at gmail.com>
Date: Sat Nov 7 02:00:04 2015 +0400
Micro optimization to hb_utf16_t and hb_utf32_t ::prev()
Implement reverse lookup instead of re-using next()
diff --git a/src/hb-utf-private.hh b/src/hb-utf-private.hh
index dfdcab2..74cf5d6 100644
--- a/src/hb-utf-private.hh
+++ b/src/hb-utf-private.hh
@@ -170,8 +170,7 @@ struct hb_utf16_t
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
- const uint16_t *end = text--;
- hb_codepoint_t c = *text;
+ hb_codepoint_t c = *--text;
if (likely (!hb_in_range (c, 0xD800u, 0xDFFFu)))
{
@@ -179,14 +178,22 @@ struct hb_utf16_t
return text;
}
- if (likely (start < text && hb_in_range (c, 0xDC00u, 0xDFFFu)))
- text--;
-
- if (likely (next (text, end, unicode, replacement) == end))
- return text;
+ if (likely (c >= 0xDC00u && start < text))
+ {
+ /* Low-surrogate in c */
+ hb_codepoint_t h = text[-1];
+ if (likely (hb_in_range (h, 0xD800u, 0xDBFFu)))
+ {
+ /* High-surrogate in h */
+ *unicode = (h << 10) + c - ((0xD800u << 10) - 0x10000u + 0xDC00u);
+ text--;
+ return text;
+ }
+ }
+ /* Lonely / out-of-order surrogate. */
*unicode = replacement;
- return end - 1;
+ return text;
}
@@ -223,8 +230,10 @@ struct hb_utf32_t
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
- next (text - 1, text, unicode, replacement);
- return text - 1;
+ hb_codepoint_t c = *unicode = *--text;
+ if (validate && unlikely (c >= 0xD800u && (c <= 0xDFFFu || c > 0x10FFFFu)))
+ *unicode = replacement;
+ return text;
}
static inline unsigned int
commit 44ae9be7a29eebd6003cad2fdb90b40512a9c8eb
Author: Konstantin Ritt <ritt.ks at gmail.com>
Date: Sat Nov 7 01:58:38 2015 +0400
Nano optimization to hb_utf16_t and hb_utf32_t ::next()
diff --git a/src/hb-utf-private.hh b/src/hb-utf-private.hh
index 14d3c2e..dfdcab2 100644
--- a/src/hb-utf-private.hh
+++ b/src/hb-utf-private.hh
@@ -146,11 +146,11 @@ struct hb_utf16_t
return text;
}
- if (likely (hb_in_range (c, 0xD800u, 0xDBFFu)))
+ if (likely (c <= 0xDBFFu && text < end))
{
/* High-surrogate in c */
- hb_codepoint_t l;
- if (text < end && ((l = *text), likely (hb_in_range (l, 0xDC00u, 0xDFFFu))))
+ hb_codepoint_t l = *text;
+ if (likely (hb_in_range (l, 0xDC00u, 0xDFFFu)))
{
/* Low-surrogate in l */
*unicode = (c << 10) + l - ((0xD800u << 10) - 0x10000u + 0xDC00u);
@@ -211,14 +211,9 @@ struct hb_utf32_t
hb_codepoint_t *unicode,
hb_codepoint_t replacement)
{
- hb_codepoint_t c = *text++;
- if (validate && unlikely (c > 0x10FFFFu || hb_in_range (c, 0xD800u, 0xDFFFu)))
- goto error;
- *unicode = c;
- return text;
-
- error:
- *unicode = replacement;
+ hb_codepoint_t c = *unicode = *text++;
+ if (validate && unlikely (c >= 0xD800u && (c <= 0xDFFFu || c > 0x10FFFFu)))
+ *unicode = replacement;
return text;
}
More information about the HarfBuzz
mailing list