Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
a24589d4
Commit
a24589d4
authored
Sep 05, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TagBuilder: add method Commit(Tag&)
For callers that already have a Tag instance.
parent
84533b6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
TagBuilder.cxx
src/tag/TagBuilder.cxx
+15
-8
TagBuilder.hxx
src/tag/TagBuilder.hxx
+6
-0
No files found.
src/tag/TagBuilder.cxx
View file @
a24589d4
...
...
@@ -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
;
}
...
...
src/tag/TagBuilder.hxx
View file @
a24589d4
...
...
@@ -84,6 +84,12 @@ public:
void
Clear
();
/**
* Move this object to the given #Tag instance. This object
* is empty afterwards.
*/
void
Commit
(
Tag
&
tag
);
/**
* Create a new #Tag instance from data in this object. The
* returned object is owned by the caller. This object is
* empty afterwards.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment