shared: add NM_STR_HAS_PREFIX() macro

Commonly, the prefix is a string constant. We don't need to call
g_str_has_prefix() for that, which first requires strlen() on
the prefix. All the information is readily available.

Add a macro for that.
This commit is contained in:
Thomas Haller 2019-01-04 09:57:34 +01:00
parent 1f906d9214
commit e3ea8ecd33

View file

@ -829,6 +829,9 @@ fcn (void) \
#define nm_streq(s1, s2) (strcmp (s1, s2) == 0)
#define nm_streq0(s1, s2) (g_strcmp0 (s1, s2) == 0)
#define NM_STR_HAS_PREFIX(str, prefix) \
(strncmp ((str), ""prefix"", NM_STRLEN (prefix)) == 0)
/*****************************************************************************/
static inline GString *