From 315ef83b4eae5fe7792df8c3959656fd7c3c0c5e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 30 May 2022 05:09:26 -0600 Subject: [PATCH] Revert "Revert "[ot-lang] Use atomic int for cache"" This reverts commit c56ce8681c209abd147328142806769752091b1c. The revert was not intentional. Ouch! --- src/hb-ot-tag.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc index a4a951536..31ce1a1e2 100644 --- a/src/hb-ot-tag.cc +++ b/src/hb-ot-tag.cc @@ -297,13 +297,13 @@ hb_ot_tags_from_language (const char *lang_str, hb_tag_t lang_tag = hb_tag_from_string (lang_str, first_len); - static unsigned last_tag_idx; /* Poor man's cache. */ - unsigned tag_idx = last_tag_idx; + static hb_atomic_int_t last_tag_idx; /* Poor man's cache. */ + unsigned tag_idx = last_tag_idx.get_relaxed (); if (likely (tag_idx < ot_languages_len && ot_languages[tag_idx].language == lang_tag) || hb_sorted_array (ot_languages, ot_languages_len).bfind (lang_tag, &tag_idx)) { - last_tag_idx = tag_idx; + last_tag_idx.set_relaxed (tag_idx); unsigned int i; while (tag_idx != 0 && ot_languages[tag_idx].language == ot_languages[tag_idx - 1].language)