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.
This commit is contained in:
Thomas Haller
2019-02-01 15:20:48 +01:00
parent 4fab0d09a5
commit 2fa7a7c20b

View File

@@ -860,8 +860,18 @@ fcn (void) \
/*****************************************************************************/ /*****************************************************************************/
#define nm_streq(s1, s2) (strcmp (s1, s2) == 0) static inline gboolean
#define nm_streq0(s1, s2) (g_strcmp0 (s1, s2) == 0) 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) \ #define NM_STR_HAS_PREFIX(str, prefix) \
(strncmp ((str), ""prefix"", NM_STRLEN (prefix)) == 0) (strncmp ((str), ""prefix"", NM_STRLEN (prefix)) == 0)