From 2ee50d030178cede83eb9d0005fbc19f819d30fe Mon Sep 17 00:00:00 2001 From: Graham Inggs Date: Mon, 5 Feb 2018 14:48:51 +0200 Subject: Imported Upstream version 2.1.0 --- StringUtils.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'StringUtils.h') diff --git a/StringUtils.h b/StringUtils.h index 9762034..d3378b3 100644 --- a/StringUtils.h +++ b/StringUtils.h @@ -11,9 +11,14 @@ in the source distribution for its full text. #include -#define String_startsWith(s, match) (strstr((s), (match)) == (s)) +#define String_startsWith(s, match) (strncmp((s),(match),strlen(match)) == 0) #define String_contains_i(s1, s2) (strcasestr(s1, s2) != NULL) +/* + * String_startsWith gives better performance if strlen(match) can be computed + * at compile time (e.g. when they are immutable string literals). :) + */ + char* String_cat(const char* s1, const char* s2); char* String_trim(const char* in); -- cgit v1.2.3