aboutsummaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-04-24 10:47:53 +0200
committerMax Kellermann <max@duempel.org>2014-04-24 10:47:53 +0200
commit986dd2fac1269b2d40f2ba2b2636eb5d312dc773 (patch)
treefe3a38140fc9e60f90e6cd2fa9c9bc3305fbd074 /src/db
parent3965b490a953398eb8e66adbe78fdd2a8fdd09d7 (diff)
downloadmpd-986dd2fac1269b2d40f2ba2b2636eb5d312dc773.tar.gz
mpd-986dd2fac1269b2d40f2ba2b2636eb5d312dc773.tar.xz
mpd-986dd2fac1269b2d40f2ba2b2636eb5d312dc773.zip
db/Helpers: move code to CheckUniqueTag()
Diffstat (limited to 'src/db')
-rw-r--r--src/db/Helpers.cxx18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/db/Helpers.cxx b/src/db/Helpers.cxx
index c6c7e3642..719fa8741 100644
--- a/src/db/Helpers.cxx
+++ b/src/db/Helpers.cxx
@@ -39,20 +39,26 @@ struct StringLess {
typedef std::set<const char *, StringLess> StringSet;
static bool
-CollectTags(StringSet &set, TagType tag_type, const LightSong &song)
+CheckUniqueTag(StringSet &set, const Tag &tag, TagType type)
{
- assert(song.tag != nullptr);
- const Tag &tag = *song.tag;
-
bool found = false;
for (unsigned i = 0; i < tag.num_items; ++i) {
- if (tag.items[i]->type == tag_type) {
+ if (tag.items[i]->type == type) {
set.insert(tag.items[i]->value);
found = true;
}
}
- if (!found)
+ return found;
+}
+
+static bool
+CollectTags(StringSet &set, TagType tag_type, const LightSong &song)
+{
+ assert(song.tag != nullptr);
+ const Tag &tag = *song.tag;
+
+ if (!CheckUniqueTag(set, tag, tag_type))
set.insert("");
return true;