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
07f212c9
Commit
07f212c9
authored
Sep 05, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SongSave: return DetachedSong, not a std::unique_ptr<>
Eliminate unnecessary dynamic allocations.
parent
a1e2602c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
12 deletions
+12
-12
SongSave.cxx
src/SongSave.cxx
+6
-6
SongSave.hxx
src/SongSave.hxx
+1
-1
DirectorySave.cxx
src/db/plugins/simple/DirectorySave.cxx
+1
-1
QueueSave.cxx
src/queue/QueueSave.cxx
+4
-4
No files found.
src/SongSave.cxx
View file @
07f212c9
...
@@ -81,11 +81,11 @@ song_save(BufferedOutputStream &os, const DetachedSong &song)
...
@@ -81,11 +81,11 @@ song_save(BufferedOutputStream &os, const DetachedSong &song)
os
.
Format
(
SONG_END
"
\n
"
);
os
.
Format
(
SONG_END
"
\n
"
);
}
}
std
::
unique_ptr
<
DetachedSong
>
DetachedSong
song_load
(
TextFile
&
file
,
const
char
*
uri
,
song_load
(
TextFile
&
file
,
const
char
*
uri
,
AudioFormat
*
audio_format_r
)
AudioFormat
*
audio_format_r
)
{
{
auto
song
=
std
::
make_unique
<
DetachedSong
>
(
uri
);
DetachedSong
song
(
uri
);
TagBuilder
tag
;
TagBuilder
tag
;
...
@@ -117,7 +117,7 @@ song_load(TextFile &file, const char *uri,
...
@@ -117,7 +117,7 @@ song_load(TextFile &file, const char *uri,
}
else
if
(
StringIsEqual
(
line
,
"Playlist"
))
{
}
else
if
(
StringIsEqual
(
line
,
"Playlist"
))
{
tag
.
SetHasPlaylist
(
StringIsEqual
(
value
,
"yes"
));
tag
.
SetHasPlaylist
(
StringIsEqual
(
value
,
"yes"
));
}
else
if
(
StringIsEqual
(
line
,
SONG_MTIME
))
{
}
else
if
(
StringIsEqual
(
line
,
SONG_MTIME
))
{
song
->
SetLastModified
(
std
::
chrono
::
system_clock
::
from_time_t
(
atoi
(
value
)));
song
.
SetLastModified
(
std
::
chrono
::
system_clock
::
from_time_t
(
atoi
(
value
)));
}
else
if
(
StringIsEqual
(
line
,
"Range"
))
{
}
else
if
(
StringIsEqual
(
line
,
"Range"
))
{
char
*
endptr
;
char
*
endptr
;
...
@@ -126,13 +126,13 @@ song_load(TextFile &file, const char *uri,
...
@@ -126,13 +126,13 @@ song_load(TextFile &file, const char *uri,
?
strtoul
(
endptr
+
1
,
nullptr
,
10
)
?
strtoul
(
endptr
+
1
,
nullptr
,
10
)
:
0
;
:
0
;
song
->
SetStartTime
(
SongTime
::
FromMS
(
start_ms
));
song
.
SetStartTime
(
SongTime
::
FromMS
(
start_ms
));
song
->
SetEndTime
(
SongTime
::
FromMS
(
end_ms
));
song
.
SetEndTime
(
SongTime
::
FromMS
(
end_ms
));
}
else
{
}
else
{
throw
FormatRuntimeError
(
"unknown line in db: %s"
,
line
);
throw
FormatRuntimeError
(
"unknown line in db: %s"
,
line
);
}
}
}
}
song
->
SetTag
(
tag
.
Commit
());
song
.
SetTag
(
tag
.
Commit
());
return
song
;
return
song
;
}
}
src/SongSave.hxx
View file @
07f212c9
...
@@ -42,7 +42,7 @@ song_save(BufferedOutputStream &os, const DetachedSong &song);
...
@@ -42,7 +42,7 @@ song_save(BufferedOutputStream &os, const DetachedSong &song);
*
*
* Throws on error.
* Throws on error.
*/
*/
std
::
unique_ptr
<
DetachedSong
>
DetachedSong
song_load
(
TextFile
&
file
,
const
char
*
uri
,
song_load
(
TextFile
&
file
,
const
char
*
uri
,
AudioFormat
*
audio_format_r
=
nullptr
);
AudioFormat
*
audio_format_r
=
nullptr
);
...
...
src/db/plugins/simple/DirectorySave.cxx
View file @
07f212c9
...
@@ -165,7 +165,7 @@ directory_load(TextFile &file, Directory &directory)
...
@@ -165,7 +165,7 @@ directory_load(TextFile &file, Directory &directory)
auto
detached_song
=
song_load
(
file
,
name
,
auto
detached_song
=
song_load
(
file
,
name
,
&
audio_format
);
&
audio_format
);
auto
song
=
std
::
make_unique
<
Song
>
(
std
::
move
(
*
detached_song
),
auto
song
=
std
::
make_unique
<
Song
>
(
std
::
move
(
detached_song
),
directory
);
directory
);
song
->
audio_format
=
audio_format
;
song
->
audio_format
=
audio_format
;
...
...
src/queue/QueueSave.cxx
View file @
07f212c9
...
@@ -73,7 +73,7 @@ queue_save(BufferedOutputStream &os, const Queue &queue)
...
@@ -73,7 +73,7 @@ queue_save(BufferedOutputStream &os, const Queue &queue)
}
}
}
}
static
std
::
unique_ptr
<
DetachedSong
>
static
DetachedSong
LoadQueueSong
(
TextFile
&
file
,
const
char
*
line
)
LoadQueueSong
(
TextFile
&
file
,
const
char
*
line
)
{
{
std
::
unique_ptr
<
DetachedSong
>
song
;
std
::
unique_ptr
<
DetachedSong
>
song
;
...
@@ -89,7 +89,7 @@ LoadQueueSong(TextFile &file, const char *line)
...
@@ -89,7 +89,7 @@ LoadQueueSong(TextFile &file, const char *line)
const
char
*
uri
=
endptr
+
1
;
const
char
*
uri
=
endptr
+
1
;
return
std
::
make_unique
<
DetachedSong
>
(
uri
);
return
DetachedSong
(
uri
);
}
}
}
}
...
@@ -112,8 +112,8 @@ queue_load_song(TextFile &file, const SongLoader &loader,
...
@@ -112,8 +112,8 @@ queue_load_song(TextFile &file, const SongLoader &loader,
auto
song
=
LoadQueueSong
(
file
,
line
);
auto
song
=
LoadQueueSong
(
file
,
line
);
if
(
!
playlist_check_translate_song
(
*
song
,
nullptr
,
loader
))
if
(
!
playlist_check_translate_song
(
song
,
nullptr
,
loader
))
return
;
return
;
queue
.
Append
(
std
::
move
(
*
song
),
priority
);
queue
.
Append
(
std
::
move
(
song
),
priority
);
}
}
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