[gegl/wip/nielsdg/null-marshallers] Use NULL c_handler for "simple" GObject signals



commit 17fe7cea2cd6f0c9950344099fb45fbd0a90d6ed
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Thu May 21 22:56:06 2020 +0200

    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()`.

 gegl/buffer/gegl-buffer.c       |  4 +---
 gegl/buffer/gegl-tile-storage.c |  4 +---
 gegl/graph/gegl-cache.c         |  8 ++------
 gegl/graph/gegl-node.c          | 12 +++---------
 gegl/module/geglmodule.c        |  3 +--
 gegl/module/geglmoduledb.c      |  9 +++------
 gegl/property-types/gegl-path.c |  7 ++-----
 7 files changed, 13 insertions(+), 34 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index 2bbc6b687..6c6926ebd 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -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);
 
diff --git a/gegl/buffer/gegl-tile-storage.c b/gegl/buffer/gegl-tile-storage.c
index bfc56c711..05198f896 100644
--- a/gegl/buffer/gegl-tile-storage.c
+++ b/gegl/buffer/gegl-tile-storage.c
@@ -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);
 }
diff --git a/gegl/graph/gegl-cache.c b/gegl/graph/gegl-cache.c
index 33036bc37..81e160aeb 100644
--- a/gegl/graph/gegl-cache.c
+++ b/gegl/graph/gegl-cache.c
@@ -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);
 }
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index 530338fd5..448fe5626 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -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);
 }
 
diff --git a/gegl/module/geglmodule.c b/gegl/module/geglmodule.c
index 27f8462ce..953b64d29 100644
--- a/gegl/module/geglmodule.c
+++ b/gegl/module/geglmodule.c
@@ -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;
diff --git a/gegl/module/geglmoduledb.c b/gegl/module/geglmoduledb.c
index f7d7936f0..85e63197f 100644
--- a/gegl/module/geglmoduledb.c
+++ b/gegl/module/geglmoduledb.c
@@ -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);
 
diff --git a/gegl/property-types/gegl-path.c b/gegl/property-types/gegl-path.c
index 7f9123ddb..922723921 100644
--- a/gegl/property-types/gegl-path.c
+++ b/gegl/property-types/gegl-path.c
@@ -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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]