提交 1f66c3c1 编写于 作者: B Behdad Esfahbod

Add hb_utf_strlen()

Speeds up UTF-8 parsing by calling strlen().
上级 7f19ae7b
......@@ -30,9 +30,6 @@
#include "hb-buffer-private.hh"
#include "hb-utf-private.hh"
#include <string.h>
#ifndef HB_DEBUG_BUFFER
#define HB_DEBUG_BUFFER (HB_DEBUG+0)
......@@ -812,14 +809,8 @@ hb_buffer_add_utf (hb_buffer_t *buffer,
if (unlikely (hb_object_is_inert (buffer)))
return;
if (text_length == -1) {
text_length = 0;
const T *p = (const T *) text;
while (*p) {
text_length++;
p++;
}
}
if (text_length == -1)
text_length = hb_utf_strlen (text);
if (item_length == -1)
item_length = text_length - item_offset;
......
......@@ -72,6 +72,12 @@ hb_utf_next (const uint8_t *text,
}
}
static inline unsigned int
hb_utf_strlen (const uint8_t *text)
{
return strlen ((const char *) text);
}
/* UTF-16 */
......@@ -97,6 +103,14 @@ hb_utf_next (const uint16_t *text,
return text;
}
static inline unsigned int
hb_utf_strlen (const uint16_t *text)
{
unsigned int l = 0;
while (*text++) l++;
return l;
}
/* UTF-32 */
......@@ -109,5 +123,13 @@ hb_utf_next (const uint32_t *text,
return text + 1;
}
static inline unsigned int
hb_utf_strlen (const uint32_t *text)
{
unsigned int l = 0;
while (*text++) l++;
return l;
}
#endif /* HB_UTF_PRIVATE_HH */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册