Re: NM coding style regarding private gobject data



Hi, it seems the opaque pointer is not faster anymore [1] and, as you said, wastes one pointer of memory, so what about nm_type_name_get_instance_private? [1]

[1] https://www.bassi.io/tag/gobject/

--
Álex Puchades

El 29/04/2015 12:00, "Thomas Haller" <thaller redhat com> escribió:
Hi,


in NM code, we tend to have gobject (duhh) with private data.
We almost always define a macro NM_TYPE_NAME_GET_PRIVATE() as accessor.



I think this long name is quite cumbersome to write. It's a bit redeemed
as we often cache that pointer in a @priv member, but you still have to
add
   NMTypeNamePrivate *priv = NM_TYPE_NAME_GET_PRIVATE (self);
to almost all methods.




What do you think about registering an opaque "priv" pointer in the
public struct instead?


Something like


/* nm-device.h */

struct _NMDevicePrivate;

typedef struct {
    GObject parent;
    struct _NMDevicePrivate *priv;
} NMDevice;



/* nm-device.c */

typedef struct _NMDevicePrivate NMDevicePrivate;
struct _NMDevicePrivate {
    /*members*/
};
#define NM_DEVICE_GET_PRIVATE(self) (self->priv)


so, we can still continue to use NM_DEVICE_GET_PRIVATE(self), but a IMO
nicer way would be just "self->priv".




It even has better runtime performance (but consumes one pointer more
memory).



Any opinions?


Thomas



_______________________________________________
networkmanager-list mailing list
networkmanager-list gnome org
https://mail.gnome.org/mailman/listinfo/networkmanager-list



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