[gnome-color-manager] trivial: make GcmTables a singleton to save a few bytes of writable



commit 3d2d33ca17cabff7e2af24110c76d5a881f0baa0
Author: Richard Hughes <richard hughsie com>
Date:   Mon Feb 22 14:18:34 2010 +0000

    trivial: make GcmTables a singleton to save a few bytes of writable

 src/gcm-tables.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/gcm-tables.c b/src/gcm-tables.c
index ae15024..470fed4 100644
--- a/src/gcm-tables.c
+++ b/src/gcm-tables.c
@@ -55,6 +55,8 @@ enum {
 	PROP_LAST
 };
 
+static gpointer gcm_tables_object = NULL;
+
 G_DEFINE_TYPE (GcmTables, gcm_tables, G_TYPE_OBJECT)
 
 /**
@@ -254,9 +256,13 @@ gcm_tables_finalize (GObject *object)
 GcmTables *
 gcm_tables_new (void)
 {
-	GcmTables *tables;
-	tables = g_object_new (GCM_TYPE_TABLES, NULL);
-	return GCM_TABLES (tables);
+	if (gcm_tables_object != NULL) {
+		g_object_ref (gcm_tables_object);
+	} else {
+		gcm_tables_object = g_object_new (GCM_TYPE_TABLES, NULL);
+		g_object_add_weak_pointer (gcm_tables_object, &gcm_tables_object);
+	}
+	return GCM_TABLES (gcm_tables_object);
 }
 
 /***************************************************************************



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]