mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-16 09:33:48 +02:00
streamlined initialization code somewhat, removed GData node cache.
Wed Nov 23 13:35:31 2005 Tim Janik <timj@gtk.org> * glib/gdataset.c: streamlined initialization code somewhat, removed GData node cache.
This commit is contained in:
parent
02b62d08cc
commit
311094aeab
@ -1,3 +1,8 @@
|
|||||||
|
Wed Nov 23 13:35:31 2005 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gdataset.c: streamlined initialization code somewhat,
|
||||||
|
removed GData node cache.
|
||||||
|
|
||||||
2005-11-22 Matthias Clasen <mclasen@redhat.com>
|
2005-11-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/ghash.c (g_hash_table_ref):
|
* glib/ghash.c (g_hash_table_ref):
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Wed Nov 23 13:35:31 2005 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gdataset.c: streamlined initialization code somewhat,
|
||||||
|
removed GData node cache.
|
||||||
|
|
||||||
2005-11-22 Matthias Clasen <mclasen@redhat.com>
|
2005-11-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/ghash.c (g_hash_table_ref):
|
* glib/ghash.c (g_hash_table_ref):
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Wed Nov 23 13:35:31 2005 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gdataset.c: streamlined initialization code somewhat,
|
||||||
|
removed GData node cache.
|
||||||
|
|
||||||
2005-11-22 Matthias Clasen <mclasen@redhat.com>
|
2005-11-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/ghash.c (g_hash_table_ref):
|
* glib/ghash.c (g_hash_table_ref):
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
/* --- defines --- */
|
/* --- defines --- */
|
||||||
#define G_QUARK_BLOCK_SIZE (512)
|
#define G_QUARK_BLOCK_SIZE (512)
|
||||||
#define G_DATA_CACHE_MAX (512)
|
|
||||||
|
|
||||||
/* datalist pointer modifications have to be done with the g_dataset_global mutex held */
|
/* datalist pointer modifications have to be done with the g_dataset_global mutex held */
|
||||||
#define G_DATALIST_GET_POINTER(datalist) \
|
#define G_DATALIST_GET_POINTER(datalist) \
|
||||||
@ -87,9 +86,6 @@ G_LOCK_DEFINE_STATIC (g_dataset_global);
|
|||||||
static GHashTable *g_dataset_location_ht = NULL;
|
static GHashTable *g_dataset_location_ht = NULL;
|
||||||
static GDataset *g_dataset_cached = NULL; /* should this be
|
static GDataset *g_dataset_cached = NULL; /* should this be
|
||||||
threadspecific? */
|
threadspecific? */
|
||||||
static GData *g_data_cache = NULL;
|
|
||||||
static guint g_data_cache_length = 0;
|
|
||||||
|
|
||||||
G_LOCK_DEFINE_STATIC (g_quark_global);
|
G_LOCK_DEFINE_STATIC (g_quark_global);
|
||||||
static GHashTable *g_quark_ht = NULL;
|
static GHashTable *g_quark_ht = NULL;
|
||||||
static gchar **g_quarks = NULL;
|
static gchar **g_quarks = NULL;
|
||||||
@ -122,14 +118,7 @@ g_datalist_clear_i (GData **datalist)
|
|||||||
G_LOCK (g_dataset_global);
|
G_LOCK (g_dataset_global);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_data_cache_length < G_DATA_CACHE_MAX)
|
g_slice_free (GData, prev);
|
||||||
{
|
|
||||||
prev->next = g_data_cache;
|
|
||||||
g_data_cache = prev;
|
|
||||||
g_data_cache_length++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
g_slice_free (GData, prev);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,14 +242,7 @@ g_data_set_internal (GData **datalist,
|
|||||||
else
|
else
|
||||||
ret_data = list->data;
|
ret_data = list->data;
|
||||||
|
|
||||||
if (g_data_cache_length < G_DATA_CACHE_MAX)
|
g_slice_free (GData, list);
|
||||||
{
|
|
||||||
list->next = g_data_cache;
|
|
||||||
g_data_cache = list;
|
|
||||||
g_data_cache_length++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
g_slice_free (GData, list);
|
|
||||||
|
|
||||||
return ret_data;
|
return ret_data;
|
||||||
}
|
}
|
||||||
@ -304,14 +286,7 @@ g_data_set_internal (GData **datalist,
|
|||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_data_cache)
|
list = g_slice_new (GData);
|
||||||
{
|
|
||||||
list = g_data_cache;
|
|
||||||
g_data_cache = list->next;
|
|
||||||
g_data_cache_length--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
list = g_slice_new (GData);
|
|
||||||
list->next = G_DATALIST_GET_POINTER (datalist);
|
list->next = G_DATALIST_GET_POINTER (datalist);
|
||||||
list->id = key_id;
|
list->id = key_id;
|
||||||
list->data = data;
|
list->data = data;
|
||||||
@ -672,7 +647,7 @@ g_quark_to_string (GQuark quark)
|
|||||||
gchar* result = NULL;
|
gchar* result = NULL;
|
||||||
|
|
||||||
G_LOCK (g_quark_global);
|
G_LOCK (g_quark_global);
|
||||||
if (quark > 0 && quark <= g_quark_seq_id)
|
if (quark < g_quark_seq_id)
|
||||||
result = g_quarks[quark];
|
result = g_quarks[quark];
|
||||||
G_UNLOCK (g_quark_global);
|
G_UNLOCK (g_quark_global);
|
||||||
|
|
||||||
@ -687,15 +662,15 @@ g_quark_new (gchar *string)
|
|||||||
|
|
||||||
if (g_quark_seq_id % G_QUARK_BLOCK_SIZE == 0)
|
if (g_quark_seq_id % G_QUARK_BLOCK_SIZE == 0)
|
||||||
g_quarks = g_renew (gchar*, g_quarks, g_quark_seq_id + G_QUARK_BLOCK_SIZE);
|
g_quarks = g_renew (gchar*, g_quarks, g_quark_seq_id + G_QUARK_BLOCK_SIZE);
|
||||||
|
|
||||||
g_quarks[0] = NULL;
|
|
||||||
g_quark_seq_id++;
|
|
||||||
g_quarks[g_quark_seq_id] = string;
|
|
||||||
quark = g_quark_seq_id;
|
|
||||||
|
|
||||||
if (!g_quark_ht)
|
if (!g_quark_ht)
|
||||||
g_quark_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
{
|
||||||
|
g_assert (g_quark_seq_id == 0);
|
||||||
|
g_quark_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
g_quarks[g_quark_seq_id++] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
quark = g_quark_seq_id++;
|
||||||
|
g_quarks[quark] = string;
|
||||||
g_hash_table_insert (g_quark_ht, string, GUINT_TO_POINTER (quark));
|
g_hash_table_insert (g_quark_ht, string, GUINT_TO_POINTER (quark));
|
||||||
|
|
||||||
return quark;
|
return quark;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user