if (G_UNLIKELY (!fontset))
{
+ gboolean insert_in_hash = TRUE;
+
fontset = pango_core_text_fontset_new (&key, desc);
- if (G_LIKELY (fontset))
- g_hash_table_insert (ctfontmap->fontset_hash,
- pango_core_text_fontset_get_key (fontset),
- fontset);
- else
+ if (G_UNLIKELY (!fontset))
{
/* If no font(set) could be loaded, we fallback to "Sans",
* which should always work on Mac. We try to adhere to the
language);
fontset = g_hash_table_lookup (ctfontmap->fontset_hash, &key);
- if (G_UNLIKELY (!fontset))
+ if (G_LIKELY (fontset))
+ insert_in_hash = FALSE;
+ else
fontset = pango_core_text_fontset_new (&key, tmp_desc);
if (G_UNLIKELY (!fontset))
}
fontset = g_hash_table_lookup (ctfontmap->fontset_hash, &key);
- if (G_UNLIKELY (!fontset))
+ if (G_LIKELY (fontset))
+ insert_in_hash = FALSE;
+ else
fontset = pango_core_text_fontset_new (&key, tmp_desc);
if (G_UNLIKELY (!fontset))
g_error ("Could not load fallback font, bailing out.");
}
}
-
- g_hash_table_insert (ctfontmap->fontset_hash,
- pango_core_text_fontset_get_key (fontset),
- fontset);
}
+
+ if (insert_in_hash)
+ g_hash_table_insert (ctfontmap->fontset_hash,
+ pango_core_text_fontset_get_key (fontset),
+ fontset);
}
/* Cannot use pango_core_text_fontset_key_free() here */