aboutsummaryrefslogtreecommitdiffstats
path: root/src/SongFilter.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-06-25 22:43:55 +0200
committerMax Kellermann <max@duempel.org>2015-06-25 23:44:16 +0200
commit8d11577ff2b7caf846a31cbb57b2cf9eb3515961 (patch)
tree8e1173e9bdb131ddba5e5166b96ee4681bc00d53 /src/SongFilter.cxx
parent037d1d9ad14969947b1a9456dc716b6a22021d29 (diff)
downloadmpd-8d11577ff2b7caf846a31cbb57b2cf9eb3515961.tar.gz
mpd-8d11577ff2b7caf846a31cbb57b2cf9eb3515961.tar.xz
mpd-8d11577ff2b7caf846a31cbb57b2cf9eb3515961.zip
lib/icu/{Converter,Collate}: return AllocatedString
Diffstat (limited to 'src/SongFilter.cxx')
-rw-r--r--src/SongFilter.cxx15
1 files changed, 8 insertions, 7 deletions
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 <assert.h>
-#include <string.h>
#include <stdlib.h>
#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());
}
}