[glib/signal-performance: 8/10] Use builtin marshallers and va_marshallers if possible
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/signal-performance: 8/10] Use builtin marshallers and va_marshallers if possible
- Date: Fri, 2 Mar 2012 16:14:05 +0000 (UTC)
commit a3e91088ce40ed201cfe1514b0adb252394027b1
Author: Alexander Larsson <alexl redhat com>
Date: Fri Mar 2 11:20:45 2012 +0100
Use builtin marshallers and va_marshallers if possible
If the signal argumment types matches a built in standard
marshaller we use the va_marshaller for that, and also the
normal marshaller if NULL was specified (as its faster than
the generic one).
gobject/gsignal.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 51 insertions(+), 3 deletions(-)
---
diff --git a/gobject/gsignal.c b/gobject/gsignal.c
index 20f11c6..5b5d301 100644
--- a/gobject/gsignal.c
+++ b/gobject/gsignal.c
@@ -1545,6 +1545,8 @@ g_signal_newv (const gchar *signal_name,
gchar *name;
guint signal_id, i;
SignalNode *node;
+ GSignalCMarshaller builtin_c_marshaller;
+ GSignalCVaMarshaller va_marshaller;
g_return_val_if_fail (signal_name != NULL, 0);
g_return_val_if_fail (G_TYPE_IS_INSTANTIATABLE (itype) || G_TYPE_IS_INTERFACE (itype), 0);
@@ -1650,13 +1652,59 @@ g_signal_newv (const gchar *signal_name,
}
else
node->accumulator = NULL;
- node->va_marshaller = NULL;
+
+ builtin_c_marshaller = NULL;
+ va_marshaller = NULL;
+
+ /* Pick up built-in va marshallers for standard types, and
+ instead of generic marshaller if no marshaller specified */
+ if (n_params == 0 && return_type == G_TYPE_NONE)
+ {
+ builtin_c_marshaller = g_cclosure_marshal_VOID__VOID;
+ va_marshaller = g_cclosure_marshal_VOID__VOIDv;
+ }
+ else if (n_params == 1 && return_type == G_TYPE_NONE)
+ {
+#define ADD_CHECK(__type__) \
+ else if (g_type_is_a (param_types[0], G_TYPE_ ##__type__)) \
+ { \
+ builtin_c_marshaller = g_cclosure_marshal_VOID__ ## __type__; \
+ va_marshaller = g_cclosure_marshal_VOID__ ## __type__ ##v; \
+ }
+
+ if (0) {}
+ ADD_CHECK (BOOLEAN)
+ ADD_CHECK (CHAR)
+ ADD_CHECK (UCHAR)
+ ADD_CHECK (INT)
+ ADD_CHECK (UINT)
+ ADD_CHECK (LONG)
+ ADD_CHECK (ULONG)
+ ADD_CHECK (ENUM)
+ ADD_CHECK (FLAGS)
+ ADD_CHECK (FLOAT)
+ ADD_CHECK (DOUBLE)
+ ADD_CHECK (STRING)
+ ADD_CHECK (PARAM)
+ ADD_CHECK (BOXED)
+ ADD_CHECK (POINTER)
+ ADD_CHECK (OBJECT)
+ ADD_CHECK (VARIANT)
+ }
+
if (c_marshaller == NULL)
{
- c_marshaller = g_cclosure_marshal_generic;
- node->va_marshaller = g_cclosure_marshal_generic_va;
+ if (builtin_c_marshaller)
+ c_marshaller = builtin_c_marshaller;
+ else
+ {
+ c_marshaller = g_cclosure_marshal_generic;
+ va_marshaller = g_cclosure_marshal_generic_va;
+ }
}
+
node->c_marshaller = c_marshaller;
+ node->va_marshaller = va_marshaller;
node->emission_hooks = NULL;
if (class_closure)
signal_add_class_closure (node, 0, class_closure);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]