From dfc1726f91d14d4af94a8959f63a492c94ee7b32 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 15 Oct 2012 18:10:42 -0500 Subject: Use threadsafe hashtable in PangoContext font cache --- pango/pango-context.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pango/pango-context.c b/pango/pango-context.c index 341f92a6..8ae01413 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -30,6 +30,7 @@ #include "pango-engine-private.h" #include "pango-modules.h" #include "pango-script-private.h" +#include "pango-threadsafe.h" struct _PangoContext { @@ -560,7 +561,7 @@ advance_attr_iterator_to (PangoAttrIterator *iterator, ***************************************************************************/ typedef struct { - GHashTable *hash; + PHashTable *hash; } ShaperFontCache; typedef struct { @@ -571,7 +572,7 @@ typedef struct { static void shaper_font_cache_destroy (ShaperFontCache *cache) { - g_hash_table_destroy (cache->hash); + p_hash_table_destroy (cache->hash); g_slice_free (ShaperFontCache, cache); } @@ -599,7 +600,7 @@ retry: if (G_UNLIKELY (!cache)) { cache = g_slice_new (ShaperFontCache); - cache->hash = g_hash_table_new_full (g_direct_hash, NULL, + cache->hash = p_hash_table_new_full (g_direct_hash, NULL, NULL, (GDestroyNotify)shaper_font_element_destroy); if (!g_object_replace_qdata (G_OBJECT (fontset), cache_quark, NULL, cache, (GDestroyNotify)shaper_font_cache_destroy, @@ -621,7 +622,7 @@ shaper_font_cache_get (ShaperFontCache *cache, { ShaperFontElement *element; - element = g_hash_table_lookup (cache->hash, GUINT_TO_POINTER (wc)); + element = p_hash_table_lookup (cache->hash, GUINT_TO_POINTER (wc)); if (element) { *shape_engine = element->shape_engine; @@ -643,7 +644,7 @@ shaper_font_cache_insert (ShaperFontCache *cache, element->shape_engine = shape_engine ? g_object_ref (shape_engine) : NULL; element->font = font ? g_object_ref (font) : NULL; - g_hash_table_insert (cache->hash, GUINT_TO_POINTER (wc), element); + p_hash_table_insert (cache->hash, GUINT_TO_POINTER (wc), element); } /**********************************************************************/ -- cgit v1.2.1