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).
This commit is contained in:
Alexander Larsson 2012-03-02 11:20:45 +01:00
parent 7964cda8e6
commit a3e91088ce

View File

@ -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);