aboutsummaryrefslogtreecommitdiffstats
path: root/StringUtils.h
diff options
context:
space:
mode:
authorGraham Inggs <ginggs@debian.org>2018-02-05 14:48:51 +0200
committerGraham Inggs <ginggs@debian.org>2018-02-05 14:48:51 +0200
commit2ee50d030178cede83eb9d0005fbc19f819d30fe (patch)
tree67d75c0a7c47e15bed9d0735ecf12abec4f8157b /StringUtils.h
parent31b71b67011fa52f091df6fe536a11d6d0bfb256 (diff)
downloaddebian_htop-2ee50d030178cede83eb9d0005fbc19f819d30fe.tar.gz
debian_htop-2ee50d030178cede83eb9d0005fbc19f819d30fe.tar.bz2
debian_htop-2ee50d030178cede83eb9d0005fbc19f819d30fe.zip
Imported Upstream version 2.1.0upstream/2.1.0
Diffstat (limited to 'StringUtils.h')
-rw-r--r--StringUtils.h7
1 files changed, 6 insertions, 1 deletions
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 <stdio.h>
-#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);

© 2014-2024 Faster IT GmbH | imprint | privacy policy