From b5d1a0901022d4711973740edadd87ce5913ac68 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 13 Mar 2020 20:38:40 +0100 Subject: [PATCH] util/StringUtil: pass std::string_view to StringArrayContainsCase() --- src/util/StringUtil.cxx | 22 +++------------------- src/util/StringUtil.hxx | 10 ++-------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/util/StringUtil.cxx b/src/util/StringUtil.cxx index 872fa70d8..5b5ca8663 100644 --- a/src/util/StringUtil.cxx +++ b/src/util/StringUtil.cxx @@ -18,35 +18,19 @@ */ #include "StringUtil.hxx" -#include "StringView.hxx" +#include "StringCompare.hxx" #include "CharUtil.hxx" -#include "ASCII.hxx" #include bool StringArrayContainsCase(const char *const*haystack, - const char *needle) noexcept + std::string_view needle) noexcept { assert(haystack != nullptr); - assert(needle != nullptr); for (; *haystack != nullptr; ++haystack) - if (StringEqualsCaseASCII(*haystack, needle)) - return true; - - return false; -} - -bool -StringArrayContainsCase(const char *const*haystack, - StringView needle) noexcept -{ - assert(haystack != nullptr); - assert(needle != nullptr); - - for (; *haystack != nullptr; ++haystack) - if (needle.EqualsIgnoreCase(*haystack)) + if (StringIsEqualIgnoreCase(*haystack, needle)) return true; return false; diff --git a/src/util/StringUtil.hxx b/src/util/StringUtil.hxx index 17c892433..3b599564c 100644 --- a/src/util/StringUtil.hxx +++ b/src/util/StringUtil.hxx @@ -23,8 +23,7 @@ #include "Compiler.h" #include - -struct StringView; +#include /** * Checks whether a string array contains the specified string. @@ -37,12 +36,7 @@ struct StringView; gcc_pure bool StringArrayContainsCase(const char *const*haystack, - const char *needle) noexcept; - -gcc_pure -bool -StringArrayContainsCase(const char *const*haystack, - StringView needle) noexcept; + std::string_view needle) noexcept; /** * Convert the specified ASCII string (0x00..0x7f) to upper case.