Commit 40abd7a5 authored by Christian Hergert's avatar Christian Hergert

cache: add negative lookup cache

This speeds things up a bit for large data sets
parent 5655342f
......@@ -32,6 +32,7 @@
static GHashTable *cache;
static GHashTable *resolve_cache;
static GHashTable *ignored;
void
girst_cache_set (const gchar *ns_name,
......@@ -40,8 +41,34 @@ girst_cache_set (const gchar *ns_name,
g_return_if_fail (ns_name);
g_return_if_fail (GIRST_IS_REPOSITORY (repository));
if (cache == NULL)
cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
if G_UNLIKELY (cache == NULL)
{
cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
/* Create an negative cache for things we can't resolve */
ignored = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (ignored, "GType", NULL);
g_hash_table_insert (ignored, "filename", NULL);
g_hash_table_insert (ignored, "gboolean", NULL);
g_hash_table_insert (ignored, "gchar", NULL);
g_hash_table_insert (ignored, "gdouble", NULL);
g_hash_table_insert (ignored, "gint", NULL);
g_hash_table_insert (ignored, "gint16", NULL);
g_hash_table_insert (ignored, "gint32", NULL);
g_hash_table_insert (ignored, "gint64", NULL);
g_hash_table_insert (ignored, "gint8", NULL);
g_hash_table_insert (ignored, "gpointer", NULL);
g_hash_table_insert (ignored, "gsize", NULL);
g_hash_table_insert (ignored, "gssize", NULL);
g_hash_table_insert (ignored, "guint", NULL);
g_hash_table_insert (ignored, "guint16", NULL);
g_hash_table_insert (ignored, "guint32", NULL);
g_hash_table_insert (ignored, "guint64", NULL);
g_hash_table_insert (ignored, "guint8", NULL);
g_hash_table_insert (ignored, "none", NULL);
g_hash_table_insert (ignored, "utf8", NULL);
}
g_hash_table_insert (cache, g_strdup (ns_name), g_object_ref (repository));
}
......@@ -76,6 +103,9 @@ girst_cache_resolve (const gchar *ns_name,
if G_UNLIKELY (cache == NULL)
return NULL;
if (g_hash_table_contains (ignored, type_name))
return NULL;
resolve_key = g_strdup_printf ("%s|%s", ns_name, type_name);
if G_UNLIKELY (resolve_cache == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment