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