From 8d11577ff2b7caf846a31cbb57b2cf9eb3515961 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 25 Jun 2015 22:43:55 +0200 Subject: lib/icu/{Converter,Collate}: return AllocatedString --- src/SongFilter.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/SongFilter.cxx') diff --git a/src/SongFilter.cxx b/src/SongFilter.cxx index 5860b5ddd..4fc7145da 100644 --- a/src/SongFilter.cxx +++ b/src/SongFilter.cxx @@ -23,12 +23,12 @@ #include "DetachedSong.hxx" #include "tag/Tag.hxx" #include "util/ConstBuffer.hxx" +#include "util/StringAPI.hxx" #include "util/ASCII.hxx" #include "util/UriUtil.hxx" #include "lib/icu/Collate.hxx" #include -#include #include #define LOCATE_TAG_FILE_KEY "file" @@ -55,12 +55,12 @@ locate_parse_type(const char *str) } gcc_pure -static std::string +static AllocatedString<> ImportString(const char *p, bool fold_case) { return fold_case ? IcuCaseFold(p) - : std::string(p); + : AllocatedString<>::Duplicate(p); } SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case) @@ -70,7 +70,7 @@ SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case) } SongFilter::Item::Item(unsigned _tag, time_t _time) - :tag(_tag), time(_time) + :tag(_tag), value(nullptr), time(_time) { } @@ -85,10 +85,11 @@ SongFilter::Item::StringMatch(const char *s) const assert(tag != LOCATE_TAG_MODIFIED_SINCE); if (fold_case) { - const std::string folded = IcuCaseFold(s); - return folded.find(value) != folded.npos; + const auto folded = IcuCaseFold(s); + assert(!folded.IsNull()); + return StringFind(folded.c_str(), value.c_str()) != nullptr; } else { - return s == value; + return StringIsEqual(s, value.c_str()); } } -- cgit v1.2.3