Re: [PATCH 1/1] device: cache pointer to private-data in NMDevice structure



On Mon, 2015-12-07 at 11:45 -0600, Dan Williams wrote:
On Mon, 2015-12-07 at 17:05 +0100, Thomas Haller wrote:
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.

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
more sense for NMDevice, where the change pays off better due to
the
class' size and ubiquitous use.


Works for me.

Dan


Thanks. merged:

http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=04c70c76bccf86a5870d957c35d4cff69ae5e558


Thomas

Attachment: signature.asc
Description: This is a digitally signed message part



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