Commit 36d8b941 authored by Benjamin Otte's avatar Benjamin Otte

signal: Keep only one list of emissions

There is no need to keep 2 lists.

This simplifies the code and gets rid of the only user inside glib of
G_HAVE_GROWING_STACK.

https://bugzilla.gnome.org/show_bug.cgi?id=736284
parent 58ec89ea
...@@ -153,12 +153,9 @@ static inline void handler_unref_R (guint signal_id, ...@@ -153,12 +153,9 @@ static inline void handler_unref_R (guint signal_id,
Handler *handler); Handler *handler);
static gint handler_lists_cmp (gconstpointer node1, static gint handler_lists_cmp (gconstpointer node1,
gconstpointer node2); gconstpointer node2);
static inline void emission_push (Emission **emission_list_p, static inline void emission_push (Emission *emission);
Emission *emission); static inline void emission_pop (Emission *emission);
static inline void emission_pop (Emission **emission_list_p, static inline Emission* emission_find (guint signal_id,
Emission *emission);
static inline Emission* emission_find (Emission *emission_list,
guint signal_id,
GQuark detail, GQuark detail,
gpointer instance); gpointer instance);
static gint class_closures_cmp (gconstpointer node1, static gint class_closures_cmp (gconstpointer node1,
...@@ -289,8 +286,7 @@ static GBSearchConfig g_class_closure_bconfig = { ...@@ -289,8 +286,7 @@ static GBSearchConfig g_class_closure_bconfig = {
0, 0,
}; };
static GHashTable *g_handler_list_bsa_ht = NULL; static GHashTable *g_handler_list_bsa_ht = NULL;
static Emission *g_recursive_emissions = NULL; static Emission *g_emissions = NULL;
static Emission *g_restart_emissions = NULL;
static gulong g_handler_sequential_number = 1; static gulong g_handler_sequential_number = 1;
G_LOCK_DEFINE_STATIC (g_signal_mutex); G_LOCK_DEFINE_STATIC (g_signal_mutex);
#define SIGNAL_LOCK() G_LOCK (g_signal_mutex) #define SIGNAL_LOCK() G_LOCK (g_signal_mutex)
...@@ -731,40 +727,37 @@ node_update_single_va_closure (SignalNode *node) ...@@ -731,40 +727,37 @@ node_update_single_va_closure (SignalNode *node)
} }
static inline void static inline void
emission_push (Emission **emission_list_p, emission_push (Emission *emission)
Emission *emission)
{ {
emission->next = *emission_list_p; emission->next = g_emissions;
*emission_list_p = emission; g_emissions = emission;
} }
static inline void static inline void
emission_pop (Emission **emission_list_p, emission_pop (Emission *emission)
Emission *emission)
{ {
Emission *node, *last = NULL; Emission *node, *last = NULL;
for (node = *emission_list_p; node; last = node, node = last->next) for (node = g_emissions; node; last = node, node = last->next)
if (node == emission) if (node == emission)
{ {
if (last) if (last)
last->next = node->next; last->next = node->next;
else else
*emission_list_p = node->next; g_emissions = node->next;
return; return;
} }
g_assert_not_reached (); g_assert_not_reached ();
} }
static inline Emission* static inline Emission*
emission_find (Emission *emission_list, emission_find (guint signal_id,
guint signal_id,
GQuark detail, GQuark detail,
gpointer instance) gpointer instance)
{ {
Emission *emission; Emission *emission;
for (emission = emission_list; emission; emission = emission->next) for (emission = g_emissions; emission; emission = emission->next)
if (emission->instance == instance && if (emission->instance == instance &&
emission->ihint.signal_id == signal_id && emission->ihint.signal_id == signal_id &&
emission->ihint.detail == detail) emission->ihint.detail == detail)
...@@ -775,26 +768,13 @@ emission_find (Emission *emission_list, ...@@ -775,26 +768,13 @@ emission_find (Emission *emission_list,
static inline Emission* static inline Emission*
emission_find_innermost (gpointer instance) emission_find_innermost (gpointer instance)
{ {
Emission *emission, *s = NULL, *c = NULL; Emission *emission;
for (emission = g_restart_emissions; emission; emission = emission->next) for (emission = g_emissions; emission; emission = emission->next)
if (emission->instance == instance)
{
s = emission;
break;
}
for (emission = g_recursive_emissions; emission; emission = emission->next)
if (emission->instance == instance) if (emission->instance == instance)
{ return emission;
c = emission;
break; return NULL;
}
if (!s)
return c;
else if (!c)
return s;
else
return G_HAVE_GROWING_STACK ? MAX (c, s) : MIN (c, s);
} }
static gint static gint
...@@ -884,8 +864,7 @@ g_signal_stop_emission (gpointer instance, ...@@ -884,8 +864,7 @@ g_signal_stop_emission (gpointer instance,
} }
if (node && g_type_is_a (G_TYPE_FROM_INSTANCE (instance), node->itype)) if (node && g_type_is_a (G_TYPE_FROM_INSTANCE (instance), node->itype))
{ {
Emission *emission_list = node->flags & G_SIGNAL_NO_RECURSE ? g_restart_emissions : g_recursive_emissions; Emission *emission = emission_find (signal_id, detail, instance);
Emission *emission = emission_find (emission_list, signal_id, detail, instance);
if (emission) if (emission)
{ {
...@@ -1149,8 +1128,7 @@ g_signal_stop_emission_by_name (gpointer instance, ...@@ -1149,8 +1128,7 @@ g_signal_stop_emission_by_name (gpointer instance,
G_STRLOC, detailed_signal, instance, g_type_name (itype)); G_STRLOC, detailed_signal, instance, g_type_name (itype));
else else
{ {
Emission *emission_list = node->flags & G_SIGNAL_NO_RECURSE ? g_restart_emissions : g_recursive_emissions; Emission *emission = emission_find (signal_id, detail, instance);
Emission *emission = emission_find (emission_list, signal_id, detail, instance);
if (emission) if (emission)
{ {
...@@ -1868,8 +1846,7 @@ signal_destroy_R (SignalNode *signal_node) ...@@ -1868,8 +1846,7 @@ signal_destroy_R (SignalNode *signal_node)
{ {
Emission *emission; Emission *emission;
for (emission = (node.flags & G_SIGNAL_NO_RECURSE) ? g_restart_emissions : g_recursive_emissions; for (emission = g_emissions; emission; emission = emission->next)
emission; emission = emission->next)
if (emission->ihint.signal_id == node.signal_id) if (emission->ihint.signal_id == node.signal_id)
g_critical (G_STRLOC ": signal \"%s\" being destroyed is currently in emission (instance '%p')", g_critical (G_STRLOC ": signal \"%s\" being destroyed is currently in emission (instance '%p')",
node.name, emission->instance); node.name, emission->instance);
...@@ -3197,7 +3174,7 @@ g_signal_emit_valist (gpointer instance, ...@@ -3197,7 +3174,7 @@ g_signal_emit_valist (gpointer instance,
emission.ihint.run_type = run_type; emission.ihint.run_type = run_type;
emission.state = EMISSION_RUN; emission.state = EMISSION_RUN;
emission.chain_type = instance_type; emission.chain_type = instance_type;
emission_push (&g_recursive_emissions, &emission); emission_push (&emission);
if (fastpath_handler) if (fastpath_handler)
handler_ref (fastpath_handler); handler_ref (fastpath_handler);
...@@ -3227,7 +3204,7 @@ g_signal_emit_valist (gpointer instance, ...@@ -3227,7 +3204,7 @@ g_signal_emit_valist (gpointer instance,
SIGNAL_LOCK (); SIGNAL_LOCK ();
emission.chain_type = G_TYPE_NONE; emission.chain_type = G_TYPE_NONE;
emission_pop (&g_recursive_emissions, &emission); emission_pop (&emission);
if (fastpath_handler) if (fastpath_handler)
handler_unref_R (signal_id, instance, fastpath_handler); handler_unref_R (signal_id, instance, fastpath_handler);
...@@ -3434,7 +3411,7 @@ signal_emit_unlocked_R (SignalNode *node, ...@@ -3434,7 +3411,7 @@ signal_emit_unlocked_R (SignalNode *node,
if (node->flags & G_SIGNAL_NO_RECURSE) if (node->flags & G_SIGNAL_NO_RECURSE)
{ {
Emission *node = emission_find (g_restart_emissions, signal_id, detail, instance); Emission *node = emission_find (signal_id, detail, instance);
if (node) if (node)
{ {
...@@ -3459,7 +3436,7 @@ signal_emit_unlocked_R (SignalNode *node, ...@@ -3459,7 +3436,7 @@ signal_emit_unlocked_R (SignalNode *node,
emission.ihint.run_type = 0; emission.ihint.run_type = 0;
emission.state = 0; emission.state = 0;
emission.chain_type = G_TYPE_NONE; emission.chain_type = G_TYPE_NONE;
emission_push ((node->flags & G_SIGNAL_NO_RECURSE) ? &g_restart_emissions : &g_recursive_emissions, &emission); emission_push (&emission);
class_closure = signal_lookup_closure (node, instance); class_closure = signal_lookup_closure (node, instance);
EMIT_RESTART: EMIT_RESTART:
...@@ -3683,7 +3660,7 @@ signal_emit_unlocked_R (SignalNode *node, ...@@ -3683,7 +3660,7 @@ signal_emit_unlocked_R (SignalNode *node,
if (handler_list) if (handler_list)
handler_unref_R (signal_id, instance, handler_list); handler_unref_R (signal_id, instance, handler_list);
emission_pop ((node->flags & G_SIGNAL_NO_RECURSE) ? &g_restart_emissions : &g_recursive_emissions, &emission); emission_pop (&emission);
SIGNAL_UNLOCK (); SIGNAL_UNLOCK ();
if (accumulator) if (accumulator)
g_value_unset (&accu); g_value_unset (&accu);
......
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