From 2fa7a7c20b2d1706e2fe6231d7844f0d25313aa5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 1 Feb 2019 15:20:48 +0100 Subject: shared: make nm_streq() and nm_streq0() inline functions There is no advantage in having these as macros. Make them inline functions, compiler should be able to decide that they are in fact inlinable. Also, don't call g_strcmp0() for nm_streq0(). It means we first have to call glib function, only to call a glibc function. No need for this abstraction. --- shared/nm-utils/nm-macros-internal.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h index 6a62be103e..42299c9635 100644 --- a/shared/nm-utils/nm-macros-internal.h +++ b/shared/nm-utils/nm-macros-internal.h @@ -860,8 +860,18 @@ fcn (void) \ /*****************************************************************************/ -#define nm_streq(s1, s2) (strcmp (s1, s2) == 0) -#define nm_streq0(s1, s2) (g_strcmp0 (s1, s2) == 0) +static inline gboolean +nm_streq (const char *s1, const char *s2) +{ + return strcmp (s1, s2) == 0; +} + +static inline gboolean +nm_streq0 (const char *s1, const char *s2) +{ + return (s1 == s2) + || (s1 && s2 && strcmp (s1, s2) == 0); +} #define NM_STR_HAS_PREFIX(str, prefix) \ (strncmp ((str), ""prefix"", NM_STRLEN (prefix)) == 0) -- cgit v1.2.1