summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2013-12-12 11:22:53 +0100
committerDan Williams <dcbw@redhat.com>2013-12-17 17:18:14 -0600
commitb7f6169dbd53e7eeb3d1aea159275a369d718ac5 (patch)
treeff42583f7ba73d7254579c1b66966218417e968e
parentd988a52967485c763942fccd6b75a5cd45977b74 (diff)
downloadNetworkManager-b7f6169dbd53e7eeb3d1aea159275a369d718ac5.tar.gz
libnm-util: minor refactoring in nm_connection_compare()
Evaluate a cheaper comparison first, to fail early Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--libnm-util/nm-connection.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index 991fed62a8..7a4e219cec 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -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;
}