aboutsummaryrefslogtreecommitdiffstats
path: root/src/tag/TagBuilder.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-09-05 19:23:06 +0200
committerMax Kellermann <max@duempel.org>2013-09-05 19:23:06 +0200
commita24589d46e822975fcd81a72a3d29d3c3e340277 (patch)
tree260ed61d82c02f2bc644f4a87b0b4e4a54e5ba6f /src/tag/TagBuilder.cxx
parent84533b6cad78626b27ceb463282687918653b605 (diff)
downloadmpd-a24589d46e822975fcd81a72a3d29d3c3e340277.tar.gz
mpd-a24589d46e822975fcd81a72a3d29d3c3e340277.tar.xz
mpd-a24589d46e822975fcd81a72a3d29d3c3e340277.zip
TagBuilder: add method Commit(Tag&)
For callers that already have a Tag instance.
Diffstat (limited to 'src/tag/TagBuilder.cxx')
-rw-r--r--src/tag/TagBuilder.cxx23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/tag/TagBuilder.cxx b/src/tag/TagBuilder.cxx
index d1babdadb..23409fe33 100644
--- a/src/tag/TagBuilder.cxx
+++ b/src/tag/TagBuilder.cxx
@@ -43,27 +43,34 @@ TagBuilder::Clear()
items.clear();
}
-Tag *
-TagBuilder::Commit()
+void
+TagBuilder::Commit(Tag &tag)
{
- Tag *tag = new Tag();
- tag->time = time;
- tag->has_playlist = has_playlist;
+ tag.Clear();
+
+ tag.time = time;
+ tag.has_playlist = has_playlist;
/* move all TagItem pointers to the new Tag object without
touching the TagPool reference counters; the
vector::clear() call is important to detach them from this
object */
const unsigned n_items = items.size();
- tag->num_items = n_items;
- tag->items = g_new(TagItem *, n_items);
- std::copy_n(items.begin(), n_items, tag->items);
+ tag.num_items = n_items;
+ tag.items = g_new(TagItem *, n_items);
+ std::copy_n(items.begin(), n_items, tag.items);
items.clear();
/* now ensure that this object is fresh (will not delete any
items because we've already moved them out) */
Clear();
+}
+Tag *
+TagBuilder::Commit()
+{
+ Tag *tag = new Tag();
+ Commit(*tag);
return tag;
}