mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-20 11:40:33 +01:00
all: don't use g_direct_equal() for hash table equality function
GHashTable optimizes a NULL equality function to use direct pointer comparison. That saves the overhead of calling g_direct_equal(). This is also documented behavior for g_hash_table_new(). While at it, also don't pass g_direct_hash() but use the default of %NULL. The behavior is the same, but consistently don't use g_direct_hash().
This commit is contained in:
parent
3ee8de20c4
commit
b58481b31e
14 changed files with 19 additions and 19 deletions
|
|
@ -157,7 +157,7 @@ nm_client_init (NMClient *client)
|
|||
|
||||
priv->state = NM_STATE_UNKNOWN;
|
||||
|
||||
priv->permissions = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
priv->permissions = g_hash_table_new (NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ nm_manager_init (NMManager *manager)
|
|||
priv->state = NM_STATE_UNKNOWN;
|
||||
priv->connectivity = NM_CONNECTIVITY_UNKNOWN;
|
||||
|
||||
priv->permissions = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
priv->permissions = g_hash_table_new (NULL, NULL);
|
||||
priv->devices = g_ptr_array_new ();
|
||||
priv->all_devices = g_ptr_array_new ();
|
||||
priv->active_connections = g_ptr_array_new ();
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ nm_arping_manager_init (NMArpingManager *self)
|
|||
{
|
||||
NMArpingManagerPrivate *priv = NM_ARPING_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
priv->addresses = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
priv->addresses = g_hash_table_new_full (NULL, NULL,
|
||||
NULL, destroy_address_info);
|
||||
priv->state = STATE_INIT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call
|
|||
g_return_if_fail (factories_by_link == NULL);
|
||||
g_return_if_fail (factories_by_setting == NULL);
|
||||
|
||||
factories_by_link = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
|
||||
factories_by_link = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
|
||||
factories_by_setting = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, (GDestroyNotify) factories_list_unref);
|
||||
|
||||
#define _ADD_INTERNAL(get_type_fcn) \
|
||||
|
|
|
|||
|
|
@ -6217,7 +6217,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection)
|
|||
guint32 count = 0;
|
||||
|
||||
if (G_UNLIKELY (!shared_ips))
|
||||
shared_ips = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
shared_ips = g_hash_table_new (NULL, NULL);
|
||||
else {
|
||||
while (g_hash_table_lookup (shared_ips, GUINT_TO_POINTER (start + count))) {
|
||||
count += ntohl (0x100);
|
||||
|
|
@ -12072,7 +12072,7 @@ nm_device_recheck_available_connections (NMDevice *self)
|
|||
priv = NM_DEVICE_GET_PRIVATE(self);
|
||||
|
||||
if (g_hash_table_size (priv->available_connections) > 0) {
|
||||
prune_list = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
prune_list = g_hash_table_new (NULL, NULL);
|
||||
g_hash_table_iter_init (&h_iter, priv->available_connections);
|
||||
while (g_hash_table_iter_next (&h_iter, (gpointer *) &connection, NULL))
|
||||
g_hash_table_add (prune_list, connection);
|
||||
|
|
@ -14131,7 +14131,7 @@ nm_device_init (NMDevice *self)
|
|||
priv->rfkill_type = RFKILL_TYPE_UNKNOWN;
|
||||
priv->unmanaged_flags = NM_UNMANAGED_PLATFORM_INIT;
|
||||
priv->unmanaged_mask = priv->unmanaged_flags;
|
||||
priv->available_connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
|
||||
priv->available_connections = g_hash_table_new_full (NULL, NULL, g_object_unref, NULL);
|
||||
priv->ip6_saved_properties = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_free);
|
||||
priv->sys_iface_state = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ nm_dhcp_manager_init (NMDhcpManager *self)
|
|||
nm_log_info (LOGD_DHCP, "dhcp-init: Using DHCP client '%s'", client_factory->name);
|
||||
|
||||
priv->client_factory = client_factory;
|
||||
priv->clients = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
priv->clients = g_hash_table_new_full (NULL, NULL,
|
||||
NULL,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ private_server_new (const char *path,
|
|||
g_signal_connect (server, "new-connection",
|
||||
G_CALLBACK (private_server_new_connection), s);
|
||||
|
||||
s->obj_managers = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
s->obj_managers = g_hash_table_new_full (NULL, NULL,
|
||||
(GDestroyNotify) private_server_manager_destroy,
|
||||
g_free);
|
||||
s->manager = manager;
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ nm_checkpoint_init (NMCheckpoint *self)
|
|||
{
|
||||
NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self);
|
||||
|
||||
priv->devices = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
priv->devices = g_hash_table_new_full (NULL, NULL,
|
||||
NULL, device_checkpoint_destroy);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -345,8 +345,8 @@ static void
|
|||
_ensure_requests (void)
|
||||
{
|
||||
if (G_UNLIKELY (requests == NULL)) {
|
||||
requests = g_hash_table_new_full (g_direct_hash,
|
||||
g_direct_equal,
|
||||
requests = g_hash_table_new_full (NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(GDestroyNotify) dispatcher_info_free);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -501,8 +501,8 @@ nm_exported_object_create_skeletons (NMExportedObject *self,
|
|||
|
||||
ifdata->property_changed_signal_id = g_signal_lookup ("properties-changed", G_OBJECT_TYPE (ifdata->interface));
|
||||
|
||||
ifdata->pending_notifies = g_hash_table_new_full (g_direct_hash,
|
||||
g_direct_equal,
|
||||
ifdata->pending_notifies = g_hash_table_new_full (NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(GDestroyNotify) g_variant_unref);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3016,7 +3016,7 @@ find_slaves (NMManager *manager,
|
|||
s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
|
||||
g_return_val_if_fail (s_con, NULL);
|
||||
|
||||
devices = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
devices = g_hash_table_new (NULL, NULL);
|
||||
|
||||
/* Search through all connections, not only inactive ones, because
|
||||
* even if a slave was already active, it might be deactivated during
|
||||
|
|
@ -6233,7 +6233,7 @@ nm_manager_init (NMManager *self)
|
|||
priv->timestamp_update_id = g_timeout_add_seconds (300, (GSourceFunc) periodic_update_active_connection_timestamps, self);
|
||||
|
||||
priv->metered = NM_METERED_UNKNOWN;
|
||||
priv->sleep_devices = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
priv->sleep_devices = g_hash_table_new (NULL, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ ck_init (NMSessionMonitor *monitor)
|
|||
|
||||
if (g_file_query_exists (file, NULL)) {
|
||||
if ((monitor->ck.monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error))) {
|
||||
monitor->ck.cache = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
|
||||
monitor->ck.cache = g_hash_table_new_full (NULL, NULL, NULL, g_free);
|
||||
g_signal_connect (monitor->ck.monitor,
|
||||
"changed",
|
||||
G_CALLBACK (ck_changed),
|
||||
|
|
|
|||
|
|
@ -594,7 +594,7 @@ nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name)
|
|||
* further by moving children/slaves to the end. */
|
||||
g_ptr_array_sort_with_data (links, _link_get_all_presort, GINT_TO_POINTER (sort_by_name));
|
||||
|
||||
unseen = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
unseen = g_hash_table_new (NULL, NULL);
|
||||
for (i = 0; i < links->len; i++) {
|
||||
item = NMP_OBJECT_CAST_LINK (links->pdata[i]);
|
||||
nm_assert (item->ifindex > 0);
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ nm_inotify_helper_init (NMInotifyHelper *self)
|
|||
{
|
||||
NMInotifyHelperPrivate *priv = NM_INOTIFY_HELPER_GET_PRIVATE (self);
|
||||
|
||||
priv->wd_refs = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
priv->wd_refs = g_hash_table_new (NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue