Skip to content
  • Niels De Graef's avatar
    gcr, ui: Use NULL for "simple" signals · 935eb7fc
    Niels De Graef authored
    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()`.
    935eb7fc