summaryrefslogtreecommitdiff
path: root/src/SongFilter.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-09-20 23:57:28 +0200
committerMax Kellermann <max@musicpd.org>2017-09-20 23:57:28 +0200
commitf6691579def38c60477d02cf57486364e4a0245c (patch)
treeaade3121f45d605604aebcb3facee117073efce2 /src/SongFilter.cxx
parentcfc152d979f01cc78d32b571206ba77671291da0 (diff)
parent828f5f83844b072f43417066c36d7d257d63db1a (diff)
Merge branch 'v0.20.x'
Diffstat (limited to 'src/SongFilter.cxx')
-rw-r--r--src/SongFilter.cxx19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/SongFilter.cxx b/src/SongFilter.cxx
index 2bdb5b2fb..3bb8894ef 100644
--- a/src/SongFilter.cxx
+++ b/src/SongFilter.cxx
@@ -28,7 +28,7 @@
#include "util/ASCII.hxx"
#include "util/TimeParser.hxx"
#include "util/UriUtil.hxx"
-#include "lib/icu/Collate.hxx"
+#include "lib/icu/CaseFold.hxx"
#include <stdexcept>
@@ -58,17 +58,10 @@ locate_parse_type(const char *str) noexcept
return tag_name_parse_i(str);
}
-static AllocatedString<>
-ImportString(const char *p, bool fold_case)
-{
- return fold_case
- ? IcuCaseFold(p)
- : AllocatedString<>::Duplicate(p);
-}
-
SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case)
- :tag(_tag), fold_case(_fold_case),
- value(ImportString(_value, _fold_case))
+ :tag(_tag),
+ value(AllocatedString<>::Duplicate(_value)),
+ fold_case(_fold_case ? IcuCompare(value.c_str()) : IcuCompare())
{
}
@@ -89,9 +82,7 @@ SongFilter::Item::StringMatch(const char *s) const noexcept
assert(tag != LOCATE_TAG_MODIFIED_SINCE);
if (fold_case) {
- const auto folded = IcuCaseFold(s);
- assert(!folded.IsNull());
- return StringFind(folded.c_str(), value.c_str()) != nullptr;
+ return fold_case.IsIn(s);
} else {
return StringIsEqual(s, value.c_str());
}