[ot-tag] Optimize subtag_matches

Part of https://github.com/harfbuzz/harfbuzz/issues/3591
This commit is contained in:
Behdad Esfahbod 2022-05-17 16:51:51 -06:00
parent a07d818597
commit 27c11405a2
1 changed files with 4 additions and 3 deletions

View File

@ -189,18 +189,19 @@ hb_ot_tag_to_script (hb_tag_t tag)
/* hb_language_t */ /* hb_language_t */
static bool static inline bool
subtag_matches (const char *lang_str, subtag_matches (const char *lang_str,
const char *limit, const char *limit,
const char *subtag) const char *subtag)
{ {
unsigned subtag_len = strlen (subtag);
do { do {
const char *s = strstr (lang_str, subtag); const char *s = strstr (lang_str, subtag);
if (!s || s >= limit) if (!s || s >= limit)
return false; return false;
if (!ISALNUM (s[strlen (subtag)])) if (!ISALNUM (s[subtag_len]))
return true; return true;
lang_str = s + strlen (subtag); lang_str = s + subtag_len;
} while (true); } while (true);
} }