Micro-optimize hb_language_from_string()
As measured / improved by Benson Limketkai.
This commit is contained in:
parent
f2ad935e19
commit
f3159ba514
|
@ -293,21 +293,21 @@ retry:
|
|||
hb_language_t
|
||||
hb_language_from_string (const char *str, int len)
|
||||
{
|
||||
char strbuf[64];
|
||||
|
||||
if (!str || !len || !*str)
|
||||
return HB_LANGUAGE_INVALID;
|
||||
|
||||
hb_language_item_t *item = NULL;
|
||||
if (len >= 0)
|
||||
{
|
||||
/* NUL-terminate it. */
|
||||
char strbuf[64];
|
||||
len = MIN (len, (int) sizeof (strbuf) - 1);
|
||||
memcpy (strbuf, str, len);
|
||||
strbuf[len] = '\0';
|
||||
str = strbuf;
|
||||
item = lang_find_or_insert (strbuf);
|
||||
}
|
||||
|
||||
hb_language_item_t *item = lang_find_or_insert (str);
|
||||
else
|
||||
item = lang_find_or_insert (str);
|
||||
|
||||
return likely (item) ? item->lang : HB_LANGUAGE_INVALID;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue