libnm: store NMConnectionPrivate via g_object_set_qdata()
g_object_get_data() and g_object_get_qdata() end up to be identical, except that g_object_get_data() also requires to intern the string on every lookup (which involves a hash lookup and locking).
This commit is contained in:
@@ -2253,12 +2253,18 @@ nm_connection_private_free (NMConnectionPrivate *priv)
|
|||||||
static NMConnectionPrivate *
|
static NMConnectionPrivate *
|
||||||
nm_connection_get_private (NMConnection *connection)
|
nm_connection_get_private (NMConnection *connection)
|
||||||
{
|
{
|
||||||
|
static GQuark key = 0;
|
||||||
NMConnectionPrivate *priv;
|
NMConnectionPrivate *priv;
|
||||||
|
|
||||||
priv = g_object_get_data (G_OBJECT (connection), "NMConnectionPrivate");
|
nm_assert (NM_IS_CONNECTION (connection));
|
||||||
|
|
||||||
|
if (G_UNLIKELY (key == 0))
|
||||||
|
key = g_quark_from_static_string ("NMConnectionPrivate");
|
||||||
|
|
||||||
|
priv = g_object_get_qdata ((GObject *) connection, key);
|
||||||
if (!priv) {
|
if (!priv) {
|
||||||
priv = g_slice_new0 (NMConnectionPrivate);
|
priv = g_slice_new0 (NMConnectionPrivate);
|
||||||
g_object_set_data_full (G_OBJECT (connection), "NMConnectionPrivate",
|
g_object_set_qdata_full ((GObject *) connection, key,
|
||||||
priv, (GDestroyNotify) nm_connection_private_free);
|
priv, (GDestroyNotify) nm_connection_private_free);
|
||||||
|
|
||||||
priv->self = connection;
|
priv->self = connection;
|
||||||
|
Reference in New Issue
Block a user