From 2c11095eed4cf9b2a93d75da707f13286d8e6f76 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 27 Sep 2022 20:08:03 +0200 Subject: [PATCH] lib/icu/Compare: use StringStartsWith() for improved code clarity Also fixes the inverted strncmp() call. --- src/lib/icu/Compare.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/icu/Compare.cxx b/src/lib/icu/Compare.cxx index 7c6fb7d1d..109b167fc 100644 --- a/src/lib/icu/Compare.cxx +++ b/src/lib/icu/Compare.cxx @@ -20,6 +20,7 @@ #include "Compare.hxx" #include "CaseFold.hxx" #include "util/StringAPI.hxx" +#include "util/StringCompare.hxx" #include "config.h" #ifdef _WIN32 @@ -117,8 +118,7 @@ bool IcuCompare::StartsWith(const char *haystack) const noexcept { #ifdef HAVE_ICU_CASE_FOLD - return StringIsEqual(IcuCaseFold(haystack).c_str(), - needle.c_str(), strlen(needle.c_str())); + return StringStartsWith(IcuCaseFold(haystack).c_str(), needle); #elif defined(_WIN32) if (needle == nullptr) /* the MultiByteToWideChar() call in the constructor @@ -138,6 +138,6 @@ IcuCompare::StartsWith(const char *haystack) const noexcept return false; } #else - return strncmp(haystack, needle.c_str(), strlen(needle.c_str())); + return StringStartsWith(haystack, needle); #endif }