From bbe4b5719502c934e3a2f931773babd858997e43 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 9 Mar 2012 09:32:06 +0100 Subject: [PATCH] signal emission: Allocate instance_and_param with alloca This Gives a 5% performance increase in e.g. the emit-handled test. --- gobject/gsignal.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gobject/gsignal.c b/gobject/gsignal.c index fafe0aece..a45b334e3 100644 --- a/gobject/gsignal.c +++ b/gobject/gsignal.c @@ -2121,7 +2121,8 @@ g_signal_chain_from_overridden_handler (gpointer instance, va_start (var_args, instance); signal_return_type = node->return_type; - instance_and_params = g_slice_alloc0 (sizeof (GValue) * (n_params + 1)); + instance_and_params = g_alloca (sizeof (GValue) * (n_params + 1)); + memset (instance_and_params, 0, sizeof (GValue) * (n_params + 1)); param_values = instance_and_params + 1; for (i = 0; i < node->n_params; i++) @@ -2146,7 +2147,6 @@ g_signal_chain_from_overridden_handler (gpointer instance, while (i--) g_value_unset (param_values + i); - g_slice_free1 (sizeof (GValue) * (n_params + 1), instance_and_params); va_end (var_args); return; } @@ -2207,7 +2207,6 @@ g_signal_chain_from_overridden_handler (gpointer instance, for (i = 0; i < n_params; i++) g_value_unset (param_values + i); g_value_unset (instance_and_params); - g_slice_free1 (sizeof (GValue) * (n_params + 1), instance_and_params); va_end (var_args); @@ -3256,7 +3255,8 @@ g_signal_emit_valist (gpointer instance, n_params = node->n_params; signal_return_type = node->return_type; - instance_and_params = g_slice_alloc0 (sizeof (GValue) * (n_params + 1)); + instance_and_params = g_alloca (sizeof (GValue) * (n_params + 1)); + memset (instance_and_params, 0, sizeof (GValue) * (n_params + 1)); param_values = instance_and_params + 1; for (i = 0; i < node->n_params; i++) @@ -3281,7 +3281,6 @@ g_signal_emit_valist (gpointer instance, while (i--) g_value_unset (param_values + i); - g_slice_free1 (sizeof (GValue) * (n_params + 1), instance_and_params); return; } SIGNAL_LOCK (); @@ -3323,7 +3322,6 @@ g_signal_emit_valist (gpointer instance, for (i = 0; i < n_params; i++) g_value_unset (param_values + i); g_value_unset (instance_and_params); - g_slice_free1 (sizeof (GValue) * (n_params + 1), instance_and_params); } /**