From 27c11405a263ad43d24e2ed460e15f247ac06d17 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 17 May 2022 16:51:51 -0600 Subject: [PATCH] [ot-tag] Optimize subtag_matches Part of https://github.com/harfbuzz/harfbuzz/issues/3591 --- src/hb-ot-tag.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc index cca91869e..c5630fb31 100644 --- a/src/hb-ot-tag.cc +++ b/src/hb-ot-tag.cc @@ -189,18 +189,19 @@ hb_ot_tag_to_script (hb_tag_t tag) /* hb_language_t */ -static bool +static inline bool subtag_matches (const char *lang_str, const char *limit, const char *subtag) { + unsigned subtag_len = strlen (subtag); do { const char *s = strstr (lang_str, subtag); if (!s || s >= limit) return false; - if (!ISALNUM (s[strlen (subtag)])) + if (!ISALNUM (s[subtag_len])) return true; - lang_str = s + strlen (subtag); + lang_str = s + subtag_len; } while (true); }