mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-19 12:40:42 +01:00
dns: track NMDnsConfigData as keys of a dictionary
There is unnecessary overhead of tracking a separate key and value in a GHashTable. Use g_hash_table_add(). (cherry picked from commitd10d96a45c) (cherry picked from commit59d48fcc35)
This commit is contained in:
parent
0250f85b71
commit
d578c6033b
2 changed files with 9 additions and 6 deletions
|
|
@ -1671,7 +1671,7 @@ nm_dns_manager_set_ip_config (NMDnsManager *self,
|
|||
|
||||
priv = NM_DNS_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
data = g_hash_table_lookup (priv->configs, GINT_TO_POINTER (ifindex));
|
||||
data = g_hash_table_lookup (priv->configs, &ifindex);
|
||||
if (!data)
|
||||
ip_data = NULL;
|
||||
else
|
||||
|
|
@ -1687,7 +1687,7 @@ nm_dns_manager_set_ip_config (NMDnsManager *self,
|
|||
/* deleting a config doesn't invalidate the configs' sort order. */
|
||||
_ip_config_data_free (ip_data);
|
||||
if (c_list_is_empty (&data->data_lst_head))
|
||||
g_hash_table_remove (priv->configs, GINT_TO_POINTER (ifindex));
|
||||
g_hash_table_remove (priv->configs, &ifindex);
|
||||
goto changed;
|
||||
}
|
||||
|
||||
|
|
@ -1705,7 +1705,7 @@ nm_dns_manager_set_ip_config (NMDnsManager *self,
|
|||
.data_lst_head = C_LIST_INIT (data->data_lst_head),
|
||||
};
|
||||
_ASSERT_config_data (data);
|
||||
g_hash_table_insert (priv->configs, GINT_TO_POINTER (ifindex), data);
|
||||
g_hash_table_add (priv->configs, data);
|
||||
}
|
||||
|
||||
if (!ip_data)
|
||||
|
|
@ -2348,8 +2348,11 @@ nm_dns_manager_init (NMDnsManager *self)
|
|||
|
||||
priv->config = g_object_ref (nm_config_get ());
|
||||
|
||||
priv->configs = g_hash_table_new_full (nm_direct_hash, NULL,
|
||||
NULL, (GDestroyNotify) _config_data_free);
|
||||
G_STATIC_ASSERT_EXPR (G_STRUCT_OFFSET (NMDnsConfigData, ifindex) == 0);
|
||||
priv->configs = g_hash_table_new_full (nm_pint_hash,
|
||||
nm_pint_equals,
|
||||
(GDestroyNotify) _config_data_free,
|
||||
NULL);
|
||||
|
||||
/* Set the initial hash */
|
||||
compute_hash (self, NULL, NM_DNS_MANAGER_GET_PRIVATE (self)->hash);
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ typedef struct {
|
|||
} NMDnsIPConfigData;
|
||||
|
||||
typedef struct _NMDnsConfigData {
|
||||
int ifindex;
|
||||
struct _NMDnsManager *self;
|
||||
CList data_lst_head;
|
||||
int ifindex;
|
||||
} NMDnsConfigData;
|
||||
|
||||
#define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type ())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue