[gcr] gcr, ui: Use NULL for "simple" signals
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcr] gcr, ui: Use NULL for "simple" signals
- Date: Sat, 16 Jan 2021 09:56:35 +0000 (UTC)
commit 935eb7fc426244cd0e24c8b858c17482d0a88853
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sat Jan 16 10:55:29 2021 +0100
gcr, ui: Use NULL for "simple" 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()`.
gcr/gcr-collection.c | 4 ++--
gcr/gcr-parser.c | 2 +-
gcr/gcr-prompt.c | 2 +-
ui/gcr-import-button.c | 2 +-
ui/gcr-live-search.c | 3 +--
ui/gcr-renderer.c | 2 +-
ui/gcr-unlock-renderer.c | 2 +-
7 files changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/gcr/gcr-collection.c b/gcr/gcr-collection.c
index 576ba4c..54c4667 100644
--- a/gcr/gcr-collection.c
+++ b/gcr/gcr-collection.c
@@ -69,7 +69,7 @@ gcr_collection_default_init (GcrCollectionIface *iface)
*/
signals[ADDED] = g_signal_new ("added", GCR_TYPE_COLLECTION,
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GcrCollectionIface, added),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
+ NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
/**
@@ -81,7 +81,7 @@ gcr_collection_default_init (GcrCollectionIface *iface)
*/
signals[REMOVED] = g_signal_new ("removed", GCR_TYPE_COLLECTION,
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GcrCollectionIface,
removed),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
+ NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
g_once_init_leave (&initialized, 1);
diff --git a/gcr/gcr-parser.c b/gcr/gcr-parser.c
index f841535..adec310 100644
--- a/gcr/gcr-parser.c
+++ b/gcr/gcr-parser.c
@@ -2505,7 +2505,7 @@ gcr_parser_class_init (GcrParserClass *klass)
*/
signals[PARSED] = g_signal_new ("parsed", GCR_TYPE_PARSER,
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GcrParserClass, parsed),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ NULL, NULL, NULL,
G_TYPE_NONE, 0);
init_quarks ();
diff --git a/gcr/gcr-prompt.c b/gcr/gcr-prompt.c
index 997c819..403f796 100644
--- a/gcr/gcr-prompt.c
+++ b/gcr/gcr-prompt.c
@@ -248,7 +248,7 @@ gcr_prompt_default_init (GcrPromptIface *iface)
*/
signals[PROMPT_CLOSE] = g_signal_new ("prompt-close", GCR_TYPE_PROMPT, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GcrPromptIface, prompt_close),
- NULL, NULL, g_cclosure_marshal_generic,
+ NULL, NULL, NULL,
G_TYPE_NONE, 0);
g_once_init_leave (&initialized, 1);
diff --git a/ui/gcr-import-button.c b/ui/gcr-import-button.c
index f2ba6dc..56de3e7 100644
--- a/ui/gcr-import-button.c
+++ b/ui/gcr-import-button.c
@@ -524,7 +524,7 @@ gcr_import_button_class_init (GcrImportButtonClass *klass)
*/
signals[IMPORTING] = g_signal_new ("importing", GCR_TYPE_IMPORT_BUTTON, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GcrImportButtonClass, importing),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
+ NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
/**
diff --git a/ui/gcr-live-search.c b/ui/gcr-live-search.c
index 39272aa..a70bf30 100644
--- a/ui/gcr-live-search.c
+++ b/ui/gcr-live-search.c
@@ -491,8 +491,7 @@ _gcr_live_search_class_init (GcrLiveSearchClass *klass)
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
+ NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[KEYNAV] = g_signal_new ("key-navigation",
diff --git a/ui/gcr-renderer.c b/ui/gcr-renderer.c
index cd91190..4f76793 100644
--- a/ui/gcr-renderer.c
+++ b/ui/gcr-renderer.c
@@ -113,7 +113,7 @@ gcr_renderer_default_init (GcrRendererIface *iface)
*/
signals[DATA_CHANGED] = g_signal_new ("data-changed", GCR_TYPE_RENDERER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GcrRendererIface, data_changed),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE,
0);
+ NULL, NULL, NULL, G_TYPE_NONE, 0);
initialized = TRUE;
}
diff --git a/ui/gcr-unlock-renderer.c b/ui/gcr-unlock-renderer.c
index 7cb1b2e..f32dfef 100644
--- a/ui/gcr-unlock-renderer.c
+++ b/ui/gcr-unlock-renderer.c
@@ -216,7 +216,7 @@ _gcr_unlock_renderer_class_init (GcrUnlockRendererClass *klass)
signals[UNLOCK_CLICKED] = g_signal_new ("unlock-clicked", GCR_TYPE_UNLOCK_RENDERER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GcrUnlockRendererClass, unlock_clicked),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ NULL, NULL, NULL, G_TYPE_NONE, 0);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]