[ot-tags] Optimize subtag_matches() further
Part of https://github.com/harfbuzz/harfbuzz/issues/3591 Comparing before to after Benchmark Time CPU Time Old Time New CPU Old CPU New ---------------------------------------------------------------------------------------------------------------------------------------------------- BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY -0.3371 -0.3371 71 47 71 47
This commit is contained in:
parent
27c11405a2
commit
7f6e8c5536
|
@ -195,6 +195,10 @@ subtag_matches (const char *lang_str,
|
||||||
const char *subtag)
|
const char *subtag)
|
||||||
{
|
{
|
||||||
unsigned subtag_len = strlen (subtag);
|
unsigned subtag_len = strlen (subtag);
|
||||||
|
|
||||||
|
if (likely ((unsigned) (limit - lang_str) < subtag_len))
|
||||||
|
return false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
const char *s = strstr (lang_str, subtag);
|
const char *s = strstr (lang_str, subtag);
|
||||||
if (!s || s >= limit)
|
if (!s || s >= limit)
|
||||||
|
|
Loading…
Reference in New Issue