diff options
author | Max Kellermann <max@musicpd.org> | 2018-08-20 15:33:16 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-20 15:33:16 +0200 |
commit | e85b9960f0b53274cf5116e0fd339758d2614ccc (patch) | |
tree | f0bf0cf719656a1f6d59f6683309d822db3ef942 /src/util | |
parent | 75c836fbd9933c7047ff4d4d64869a5a1dafe428 (diff) |
util/StringCompare: use StringAPI.hxx
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/StringCompare.cxx | 8 | ||||
-rw-r--r-- | src/util/StringCompare.hxx | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/util/StringCompare.cxx b/src/util/StringCompare.cxx index 58ac5a2c1..7a92d75c8 100644 --- a/src/util/StringCompare.cxx +++ b/src/util/StringCompare.cxx @@ -32,8 +32,8 @@ bool StringEndsWith(const char *haystack, const char *needle) noexcept { - const size_t haystack_length = strlen(haystack); - const size_t needle_length = strlen(needle); + const size_t haystack_length = StringLength(haystack); + const size_t needle_length = StringLength(needle); return haystack_length >= needle_length && memcmp(haystack + haystack_length - needle_length, @@ -43,8 +43,8 @@ StringEndsWith(const char *haystack, const char *needle) noexcept const char * FindStringSuffix(const char *p, const char *suffix) noexcept { - const size_t p_length = strlen(p); - const size_t suffix_length = strlen(suffix); + const size_t p_length = StringLength(p); + const size_t suffix_length = StringLength(suffix); if (p_length < suffix_length) return nullptr; diff --git a/src/util/StringCompare.hxx b/src/util/StringCompare.hxx index 97c7762cf..248c12daa 100644 --- a/src/util/StringCompare.hxx +++ b/src/util/StringCompare.hxx @@ -31,6 +31,7 @@ #define STRING_COMPARE_HXX #include "StringView.hxx" +#include "StringAPI.hxx" #include "Compiler.h" #ifdef _UNICODE @@ -47,7 +48,7 @@ gcc_pure gcc_nonnull_all static inline bool StringStartsWith(const char *haystack, StringView needle) noexcept { - return strncmp(haystack, needle.data, needle.size) == 0; + return StringIsEqual(haystack, needle.data, needle.size); } gcc_pure |