From 407a29aa239dd7c4a0ee90ccd08529229457d8ce Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Fri, 4 Jul 2025 00:15:56 -0400 Subject: [PATCH] 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. --- include/common/string-helpers.h | 3 +-- src/common/string-helpers.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) 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);