[glib/wip/3v1n0/g_str_has_optimization] gstrfuncs: Use explicitly statically computed prefix/suffix length
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/3v1n0/g_str_has_optimization] gstrfuncs: Use explicitly statically computed prefix/suffix length
- Date: Thu, 13 Oct 2022 01:01:36 +0000 (UTC)
commit f0d45674885c367d0e42b1763062334017cf45e5
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Thu Oct 13 02:17:21 2022 +0200
gstrfuncs: Use explicitly statically computed prefix/suffix length
glib/gstrfuncs.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h
index ad854da590..3ae1e1eb4b 100644
--- a/glib/gstrfuncs.h
+++ b/glib/gstrfuncs.h
@@ -154,7 +154,7 @@ gboolean g_str_has_prefix (const gchar *str,
const char *const __str = ((STR)); \
const char *const __prefix = ((PREFIX)); \
const size_t __str_len = strlen (__str); \
- const size_t __prefix_len = strlen (__prefix); \
+ const size_t __prefix_len = (sizeof ((PREFIX)) / sizeof (char)) - 1; \
(__str_len >= __prefix_len) ? \
(memcmp (__str, __prefix, __prefix_len) == 0) : FALSE; \
}) \
@@ -168,7 +168,7 @@ gboolean g_str_has_prefix (const gchar *str,
const char *const __str = ((STR)); \
const char *const __suffix = ((SUFFIX)); \
const size_t __str_len = strlen (__str); \
- const size_t __suffix_len = strlen (__suffix); \
+ const size_t __suffix_len = (sizeof ((SUFFIX)) / sizeof (char)) - 1; \
(__str_len >= __suffix_len) ? \
(memcmp (__str + __str_len - __suffix_len, \
__suffix, \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]