From 8ab23e5b2d8c3dc87581ce2e090886cf0925bb5d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 26 Sep 2022 16:47:56 +0200 Subject: [PATCH] glib-aux: reorder comparison in nm_ref_string_equal_str() We usually compare first for pointer equality. It seems to make more sense this way. Swap. --- src/libnm-glib-aux/nm-ref-string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libnm-glib-aux/nm-ref-string.h b/src/libnm-glib-aux/nm-ref-string.h index 0cfea5fae3..1b0cabf26d 100644 --- a/src/libnm-glib-aux/nm-ref-string.h +++ b/src/libnm-glib-aux/nm-ref-string.h @@ -156,7 +156,7 @@ nm_ref_string_equal_str(NMRefString *rstr, const char *str) /* We don't use streq() here, because an NMRefString might have embedded NUL characters * (as the length is tracked separately). The NUL terminated C string @str must not * compare equal to such a @rstr, thus we first explicitly check strlen(). */ - return rstr->len == strlen(str) && (rstr->str == str || memcmp(rstr->str, str, rstr->len) == 0); + return rstr->str == str || (rstr->len == strlen(str) && memcmp(rstr->str, str, rstr->len) == 0); } static inline gboolean