Commit 3cffc84f authored by Niels De Graef's avatar Niels De Graef Committed by Øyvind "pippin" Kolås

Use NULL c_handler for "simple" GObject signals

Apart from being less code, this actually gives us a nice performance
improvement. Up until a few years ago, if you pass `NULL` as the
marshaller for a signal, GLib would fall back to
`g_cclosure_marshal_generic` which uses libffi to pack/unpack its
arguments. One could avoid this by specifying a more specific
marshaller which would then be used to immediately pack and unpack into
GValues with the correct type.

Lately however, as a way of optimizing signal emission (which can be
quite expensive), GLib added a possibility to set a va_marshaller, which
skips the unnecessary GValue packing and unpacking and just uses a
valist variant.

Since the performance difference is big enough, if the marshaller
argument is NULL, `g_signal_new()` will now check for the simple
marshallers (return type NONE and a single argument) and set both the
generic and the valist marshaller. In other words, less code for us with
bigger optimizations.

In case you also want va_marshallers for more complex signals, you can
use `g_signal_set_va_marshaller()`.
parent 4c943d59
Pipeline #186364 passed with stages
in 14 minutes and 1 second
......@@ -904,9 +904,7 @@ gegl_buffer_class_init (GeglBufferClass *class)
g_signal_new ("changed",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0,
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_RECTANGLE);
......
......@@ -204,9 +204,7 @@ gegl_tile_storage_class_init (GeglTileStorageClass *class)
g_signal_new ("changed",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0,
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_RECTANGLE);
}
......
......@@ -155,9 +155,7 @@ gegl_cache_class_init (GeglCacheClass *klass)
g_signal_new ("computed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0,
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_RECTANGLE);
......@@ -165,9 +163,7 @@ gegl_cache_class_init (GeglCacheClass *klass)
g_signal_new ("invalidated",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0,
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_RECTANGLE);
}
......
......@@ -209,9 +209,7 @@ gegl_node_class_init (GeglNodeClass *klass)
g_signal_new ("invalidated",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0,
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_RECTANGLE);
......@@ -219,9 +217,7 @@ gegl_node_class_init (GeglNodeClass *klass)
g_signal_new ("computed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0,
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_RECTANGLE);
......@@ -229,9 +225,7 @@ gegl_node_class_init (GeglNodeClass *klass)
g_signal_new ("progress",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0,
NULL, NULL,
g_cclosure_marshal_VOID__DOUBLE,
0, NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_DOUBLE);
}
......
......@@ -64,8 +64,7 @@ gegl_module_class_init (GeglModuleClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GeglModuleClass, modified),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
object_class->finalize = gegl_module_finalize;
......
......@@ -74,8 +74,7 @@ gegl_module_db_class_init (GeglModuleDBClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GeglModuleDBClass, add),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_MODULE);
......@@ -84,8 +83,7 @@ gegl_module_db_class_init (GeglModuleDBClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GeglModuleDBClass, remove),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_MODULE);
......@@ -94,8 +92,7 @@ gegl_module_db_class_init (GeglModuleDBClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GeglModuleDBClass, module_modified),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_MODULE);
......
......@@ -209,11 +209,8 @@ gegl_path_class_init (GeglPathClass *klass)
gegl_path_signals[GEGL_PATH_CHANGED] =
g_signal_new ("changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0 /* class offset */,
NULL /* accumulator */,
NULL /* accu_data */,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, /*return type */
0, NULL, NULL, NULL,
G_TYPE_NONE,
1, G_TYPE_POINTER);
}
......
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