Skip to content
  • Thomas Haller's avatar
    device: cache pointer to private-data in NMDevice structure · 04c70c76
    Thomas Haller authored
    We often lookup the private data and retrieve it via NM_DEVICE_GET_PRIVATE(),
    which in turn calls G_TYPE_INSTANCE_GET_PRIVATE().
    
    Instead cache the pointer to the private data.
    
    There are up- and downsides:
    
     - requries additional sizeof(gpointer) bytes for each NMDevice.
     + retrieving the private pointer will be slightly faster.
     + easier debugging in gdb as it is currently often a pain to
       retrieve the private data.
    
    But most importantly, the allows to change our common pattern
    to first cache the private data in a variable @priv. That is
    often cumbersome to write, especially for short functions.
    This change gives us a choice to use self->priv directly.
    
    Such a change should not be aimed for every class. Instead it makes
    mostly sense for NMDevice, where it pays off better due to the
    class' size and ubiquitous use.
    
    https://mail.gnome.org/archives/networkmanager-list/2015-December/msg00017.html
    04c70c76