From: John Lindgren Date: Fri, 4 Jul 2025 04:15:56 +0000 (-0400) Subject: string-helpers: remove restrict qualifier X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=407a29aa239dd7c4a0ee90ccd08529229457d8ce;p=proto%2Flabwc.git string-helpers: remove restrict qualifier 'restrict' is harmful as it encourages the compiler to make dangerous assumptions while increasing cognitive load on the human programmer. The extra 1% (or whatever) of performance here is not worth the cost. --- diff --git a/include/common/string-helpers.h b/include/common/string-helpers.h index efa5bfd2..e49fa110 100644 --- a/include/common/string-helpers.h +++ b/include/common/string-helpers.h @@ -59,8 +59,7 @@ char *strdup_printf(const char *fmt, ...); * The separator is arbitrary. When the separator is NULL, a single space will * be used. */ -char *str_join(const char *const parts[], - const char *restrict fmt, const char *restrict sep); +char *str_join(const char *const parts[], const char *fmt, const char *sep); /** * str_endswith - indicate whether a string ends with a given suffix diff --git a/src/common/string-helpers.c b/src/common/string-helpers.c index f753d1a1..f94e1dd9 100644 --- a/src/common/string-helpers.c +++ b/src/common/string-helpers.c @@ -93,8 +93,7 @@ strdup_printf(const char *fmt, ...) } char * -str_join(const char *const parts[], - const char *restrict fmt, const char *restrict sep) +str_join(const char *const parts[], const char *fmt, const char *sep) { assert(parts);