Revert "Revert "[ot-lang] Use atomic int for cache""

This reverts commit c56ce8681c.

The revert was not intentional. Ouch!
This commit is contained in:
Behdad Esfahbod 2022-05-30 05:09:26 -06:00
parent 97aa1ce6ba
commit 315ef83b4e
1 changed files with 3 additions and 3 deletions

View File

@ -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)