summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Bilien <jobi@via.ecp.fr>2008-12-10 17:53:09 +0000
committerJohan Bilien <jobi@src.gnome.org>2008-12-10 17:53:09 +0000
commit7a14ec065b88c2b797e60d7e96fd819ed14f691c (patch)
tree70af042b8fc06385e2fee03153e3cc381110c9d2
parent96d1b5d0efb045dd6f7cc42f6ea48f773d643fec (diff)
downloadgobject-introspection-7a14ec065b88c2b797e60d7e96fd819ed14f691c.tar.gz
Bug 563998 – Cache the GIBaseInfo for GTypes
2008-12-10 Johan Bilien <jobi@via.ecp.fr> Bug 563998 – Cache the GIBaseInfo for GTypes * girepository/girepository.c (g_irepository_find_by_gtype): add a cache of GType -> GIBaseInfo. svn path=/trunk/; revision=991
-rw-r--r--ChangeLog7
-rw-r--r--girepository/girepository.c18
2 files changed, 25 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b5c7d5d3..b8fcee95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-10 Johan Bilien <jobi@via.ecp.fr>
+
+ Bug 563998 – Cache the GIBaseInfo for GTypes
+
+ * girepository/girepository.c (g_irepository_find_by_gtype):
+ add a cache of GType -> GIBaseInfo.
+
2008-12-09 Johan Bilien <jobi@via.ecp.fr>
Bug 562545 – Add function taking / returning GValue
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 40fba52c..56c1e995 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -42,6 +42,7 @@ struct _GIRepositoryPrivate
{
GHashTable *typelibs; /* (string) namespace -> GTypelib */
GHashTable *lazy_typelibs; /* (string) namespace-version -> GTypelib */
+ GHashTable *info_by_gtype; /* GType -> GIBaseInfo */
};
G_DEFINE_TYPE (GIRepository, g_irepository, G_TYPE_OBJECT);
@@ -57,6 +58,10 @@ g_irepository_init (GIRepository *repository)
(GDestroyNotify) g_typelib_free);
repository->priv->lazy_typelibs
= g_hash_table_new (g_str_hash, g_str_equal);
+ repository->priv->info_by_gtype
+ = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ (GDestroyNotify) NULL,
+ (GDestroyNotify) g_base_info_unref);
}
static void
@@ -66,6 +71,7 @@ g_irepository_finalize (GObject *object)
g_hash_table_destroy (repository->priv->typelibs);
g_hash_table_destroy (repository->priv->lazy_typelibs);
+ g_hash_table_destroy (repository->priv->info_by_gtype);
(* G_OBJECT_CLASS (g_irepository_parent_class)->finalize) (G_OBJECT (repository));
}
@@ -625,6 +631,12 @@ g_irepository_find_by_gtype (GIRepository *repository,
repository = get_repository (repository);
+ data.iface = g_hash_table_lookup (repository->priv->info_by_gtype,
+ (gpointer)type);
+
+ if (data.iface)
+ return g_base_info_ref (data.iface);
+
data.repo = repository;
data.name = NULL;
data.type = g_type_name (type);
@@ -634,6 +646,12 @@ g_irepository_find_by_gtype (GIRepository *repository,
g_hash_table_foreach (repository->priv->typelibs, find_interface, &data);
g_hash_table_foreach (repository->priv->lazy_typelibs, find_interface, &data);
+ if (data.iface)
+ g_hash_table_insert (repository->priv->info_by_gtype,
+ (gpointer) type,
+ g_base_info_ref (data.iface));
+
+
return data.iface;
}