diff options
author | Thomas Haller <thaller@redhat.com> | 2019-02-01 15:20:48 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-02-13 16:03:23 +0100 |
commit | 2fa7a7c20b2d1706e2fe6231d7844f0d25313aa5 (patch) | |
tree | 77d2ba99f6753b60255285bd86b605891808343f | |
parent | 4fab0d09a5c860701826eeaa4dd1f0a20440c0b9 (diff) | |
download | NetworkManager-2fa7a7c20b2d1706e2fe6231d7844f0d25313aa5.tar.gz |
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.
-rw-r--r-- | shared/nm-utils/nm-macros-internal.h | 14 |
1 files 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) |