From 66cebd72925406910f99c0fd826b8307c2a4814c Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 29 Jun 2009 13:21:08 +0200 Subject: [PATCH] split attribute hash initialization into its own function --- gio/gfileinfo.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c index 2785a10..c9108d7 100644 --- a/gio/gfileinfo.c +++ b/gio/gfileinfo.c @@ -140,6 +140,16 @@ _lookup_namespace (const char *namespace) return ns_info; } +static void +ensure_attribute_hash (void) +{ + if (attribute_hash != NULL) + return; + + ns_hash = g_hash_table_new (g_str_hash, g_str_equal); + attribute_hash = g_hash_table_new (g_str_hash, g_str_equal); +} + static guint32 lookup_namespace (const char *namespace) { @@ -148,11 +158,7 @@ lookup_namespace (const char *namespace) G_LOCK (attribute_hash); - if (attribute_hash == NULL) - { - ns_hash = g_hash_table_new (g_str_hash, g_str_equal); - attribute_hash = g_hash_table_new (g_str_hash, g_str_equal); - } + ensure_attribute_hash (); ns_info = _lookup_namespace (namespace); id = 0; @@ -183,11 +189,7 @@ lookup_attribute (const char *attribute) NSInfo *ns_info; G_LOCK (attribute_hash); - if (attribute_hash == NULL) - { - ns_hash = g_hash_table_new (g_str_hash, g_str_equal); - attribute_hash = g_hash_table_new (g_str_hash, g_str_equal); - } + ensure_attribute_hash (); attr_id = GPOINTER_TO_UINT (g_hash_table_lookup (attribute_hash, attribute)); -- 2.7.4