diff options
author | Max Kellermann <max@musicpd.org> | 2020-04-03 15:38:26 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-04-03 16:13:14 +0200 |
commit | e620677d7ce133214809dccd29c7cec13a34716b (patch) | |
tree | 4a93ec6a0e0cadea9170c450be7b1061f8c43931 /src/lib | |
parent | 09d8e44d569aebb26628e3fa3be58b061b7a2c50 (diff) |
lib/icu/CaseFold: pass std::string_view
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/icu/CaseFold.cxx | 7 | ||||
-rw-r--r-- | src/lib/icu/CaseFold.hxx | 5 | ||||
-rw-r--r-- | src/lib/icu/Compare.cxx | 4 | ||||
-rw-r--r-- | src/lib/icu/Compare.hxx | 4 |
4 files changed, 8 insertions, 12 deletions
diff --git a/src/lib/icu/CaseFold.cxx b/src/lib/icu/CaseFold.cxx index b4fe9d8bc..74a0462a2 100644 --- a/src/lib/icu/CaseFold.cxx +++ b/src/lib/icu/CaseFold.cxx @@ -45,14 +45,9 @@ #include <string.h> AllocatedString<> -IcuCaseFold(const char *src) noexcept +IcuCaseFold(std::string_view src) noexcept try { #ifdef HAVE_ICU -#if !CLANG_CHECK_VERSION(3,6) - /* disabled on clang due to -Wtautological-pointer-compare */ - assert(src != nullptr); -#endif - const auto u = UCharFromUTF8(src); if (u.IsNull()) return AllocatedString<>::Duplicate(src); diff --git a/src/lib/icu/CaseFold.hxx b/src/lib/icu/CaseFold.hxx index 294fd1eaf..ba91262d8 100644 --- a/src/lib/icu/CaseFold.hxx +++ b/src/lib/icu/CaseFold.hxx @@ -25,13 +25,12 @@ #if defined(HAVE_ICU) || defined(_WIN32) #define HAVE_ICU_CASE_FOLD -#include "util/Compiler.h" +#include <string_view> template<typename T> class AllocatedString; -gcc_nonnull_all AllocatedString<char> -IcuCaseFold(const char *src) noexcept; +IcuCaseFold(std::string_view src) noexcept; #endif diff --git a/src/lib/icu/Compare.cxx b/src/lib/icu/Compare.cxx index dc9ed9093..1fde0a637 100644 --- a/src/lib/icu/Compare.cxx +++ b/src/lib/icu/Compare.cxx @@ -24,12 +24,12 @@ #ifdef HAVE_ICU_CASE_FOLD -IcuCompare::IcuCompare(const char *_needle) noexcept +IcuCompare::IcuCompare(std::string_view _needle) noexcept :needle(IcuCaseFold(_needle)) {} #else -IcuCompare::IcuCompare(const char *_needle) noexcept +IcuCompare::IcuCompare(std::string_view _needle) noexcept :needle(AllocatedString<>::Duplicate(_needle)) {} #endif diff --git a/src/lib/icu/Compare.hxx b/src/lib/icu/Compare.hxx index 356681f7d..832e7949c 100644 --- a/src/lib/icu/Compare.hxx +++ b/src/lib/icu/Compare.hxx @@ -23,6 +23,8 @@ #include "util/Compiler.h" #include "util/AllocatedString.hxx" +#include <string_view> + /** * This class can compare one string ("needle") with lots of other * strings ("haystacks") efficiently, ignoring case. With some @@ -34,7 +36,7 @@ class IcuCompare { public: IcuCompare():needle(nullptr) {} - explicit IcuCompare(const char *needle) noexcept; + explicit IcuCompare(std::string_view needle) noexcept; IcuCompare(const IcuCompare &src) noexcept :needle(src |