diff options
author | Max Kellermann <max@musicpd.org> | 2018-10-22 10:03:47 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-10-22 10:03:47 +0200 |
commit | ff58b8d2551eb15810180e3fca0fac7f761c9d47 (patch) | |
tree | 2d16e83c32e807e3b57a85e63c9108966f858bb6 /src/tag | |
parent | 3f3f0af543e33ede947bdb19809243064224f4d7 (diff) |
tag/Builder: move code to AddItemUnchecked()
Diffstat (limited to 'src/tag')
-rw-r--r-- | src/tag/TagBuilder.cxx | 22 | ||||
-rw-r--r-- | src/tag/TagBuilder.hxx | 6 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/tag/TagBuilder.cxx b/src/tag/TagBuilder.cxx index 43cf3cc6f..e88fc6edd 100644 --- a/src/tag/TagBuilder.cxx +++ b/src/tag/TagBuilder.cxx @@ -188,6 +188,16 @@ TagBuilder::Complement(const Tag &other) tag_pool_lock.unlock(); } +void +TagBuilder::AddItemUnchecked(TagType type, StringView value) noexcept +{ + tag_pool_lock.lock(); + auto i = tag_pool_get_item(type, value); + tag_pool_lock.unlock(); + + items.push_back(i); +} + inline void TagBuilder::AddItemInternal(TagType type, StringView value) { @@ -197,13 +207,9 @@ TagBuilder::AddItemInternal(TagType type, StringView value) if (!f.IsNull()) value = { f.data, f.size }; - tag_pool_lock.lock(); - auto i = tag_pool_get_item(type, value); - tag_pool_lock.unlock(); + AddItemUnchecked(type, value); free(f.data); - - items.push_back(i); } void @@ -229,11 +235,7 @@ TagBuilder::AddItem(TagType type, const char *value) void TagBuilder::AddEmptyItem(TagType type) { - tag_pool_lock.lock(); - auto i = tag_pool_get_item(type, StringView::Empty()); - tag_pool_lock.unlock(); - - items.push_back(i); + AddItemUnchecked(type, StringView::Empty()); } void diff --git a/src/tag/TagBuilder.hxx b/src/tag/TagBuilder.hxx index b69d23689..82ed0227b 100644 --- a/src/tag/TagBuilder.hxx +++ b/src/tag/TagBuilder.hxx @@ -133,6 +133,12 @@ public: void Complement(const Tag &other); /** + * A variant of AddItem() which does not attempt to fix up the + * value and does not check whether the tag type is disabled. + */ + void AddItemUnchecked(TagType type, StringView value) noexcept; + + /** * Appends a new tag item. * * @param type the type of the new tag item |