mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-21 18:24:49 +00:00
libnm-util: minor refactoring in nm_connection_compare()
Evaluate a cheaper comparison first, to fail early Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
d988a52967
commit
b7f6169dbd
|
@ -446,11 +446,16 @@ nm_connection_compare (NMConnection *a,
|
|||
GHashTableIter iter;
|
||||
NMSetting *src;
|
||||
|
||||
if (!a && !b)
|
||||
if (a == b)
|
||||
return TRUE;
|
||||
if (!a || !b)
|
||||
return FALSE;
|
||||
|
||||
/* B / A: ensure settings in B that are not in A make the comparison fail */
|
||||
if (g_hash_table_size (NM_CONNECTION_GET_PRIVATE (a)->settings) !=
|
||||
g_hash_table_size (NM_CONNECTION_GET_PRIVATE (b)->settings))
|
||||
return FALSE;
|
||||
|
||||
/* A / B: ensure all settings in A match corresponding ones in B */
|
||||
g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (a)->settings);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &src)) {
|
||||
|
@ -460,11 +465,6 @@ nm_connection_compare (NMConnection *a,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* B / A: ensure settings in B that are not in A make the comparison fail */
|
||||
if (g_hash_table_size (NM_CONNECTION_GET_PRIVATE (a)->settings) !=
|
||||
g_hash_table_size (NM_CONNECTION_GET_PRIVATE (b)->settings))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue