PaylistTag: use class TagBuilder

This commit is contained in:
Max Kellermann
2013-12-03 12:56:36 +01:00
parent c36af35730
commit 9f4e96fdfa
5 changed files with 54 additions and 44 deletions

View File

@@ -108,13 +108,7 @@ TagBuilder::Clear()
{
time = -1;
has_playlist = false;
tag_pool_lock.lock();
for (auto i : items)
tag_pool_put_item(i);
tag_pool_lock.unlock();
items.clear();
RemoveAll();
}
void
@@ -216,3 +210,29 @@ TagBuilder::AddItem(TagType type, const char *value)
AddItem(type, value, strlen(value));
}
void
TagBuilder::RemoveAll()
{
tag_pool_lock.lock();
for (auto i : items)
tag_pool_put_item(i);
tag_pool_lock.unlock();
items.clear();
}
void
TagBuilder::RemoveType(TagType type)
{
const auto begin = items.begin(), end = items.end();
items.erase(std::remove_if(begin, end,
[type](TagItem *item) {
if (item->type != type)
return false;
tag_pool_put_item(item);
return true;
}),
end);
}