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
f4d0bd82
Commit
f4d0bd82
authored
Aug 12, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/simple/Song: make "parent" a reference, not a pointer
parent
1bfede12
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
17 deletions
+15
-17
SongUpdate.cxx
src/SongUpdate.cxx
+2
-3
Directory.cxx
src/db/plugins/simple/Directory.cxx
+3
-3
Song.cxx
src/db/plugins/simple/Song.cxx
+5
-5
Song.hxx
src/db/plugins/simple/Song.hxx
+2
-3
Editor.cxx
src/db/update/Editor.cxx
+2
-2
Walk.cxx
src/db/update/Walk.cxx
+1
-1
No files found.
src/SongUpdate.cxx
View file @
f4d0bd82
...
...
@@ -109,12 +109,11 @@ Song::LoadFromArchive(ArchiveFile &archive, const char *name_utf8,
bool
Song
::
UpdateFileInArchive
(
ArchiveFile
&
archive
)
noexcept
{
assert
(
parent
!=
nullptr
);
assert
(
parent
->
device
==
DEVICE_INARCHIVE
);
assert
(
parent
.
device
==
DEVICE_INARCHIVE
);
std
::
string
path_utf8
(
uri
);
for
(
const
Directory
*
directory
=
parent
;
for
(
const
Directory
*
directory
=
&
parent
;
directory
->
parent
!=
nullptr
&&
directory
->
parent
->
device
==
DEVICE_INARCHIVE
;
directory
=
directory
->
parent
)
{
...
...
src/db/plugins/simple/Directory.cxx
View file @
f4d0bd82
...
...
@@ -167,7 +167,7 @@ Directory::AddSong(SongPtr song) noexcept
{
assert
(
holding_db_lock
());
assert
(
song
!=
nullptr
);
assert
(
song
->
parent
==
this
);
assert
(
&
song
->
parent
==
this
);
songs
.
push_back
(
*
song
.
release
());
}
...
...
@@ -177,7 +177,7 @@ Directory::RemoveSong(Song *song) noexcept
{
assert
(
holding_db_lock
());
assert
(
song
!=
nullptr
);
assert
(
song
->
parent
==
this
);
assert
(
&
song
->
parent
==
this
);
songs
.
erase
(
songs
.
iterator_to
(
*
song
));
}
...
...
@@ -189,7 +189,7 @@ Directory::FindSong(const char *name_utf8) const noexcept
assert
(
name_utf8
!=
nullptr
);
for
(
auto
&
song
:
songs
)
{
assert
(
song
.
parent
==
this
);
assert
(
&
song
.
parent
==
this
);
if
(
song
.
uri
==
name_utf8
)
return
&
song
;
...
...
src/db/plugins/simple/Song.cxx
View file @
f4d0bd82
...
...
@@ -26,7 +26,7 @@
inline
Song
::
Song
(
StringView
_uri
,
Directory
&
_parent
)
noexcept
:
parent
(
&
_parent
),
uri
(
_uri
.
data
,
_uri
.
size
)
:
parent
(
_parent
),
uri
(
_uri
.
data
,
_uri
.
size
)
{
}
...
...
@@ -56,10 +56,10 @@ Song::NewFile(const char *path, Directory &parent) noexcept
std
::
string
Song
::
GetURI
()
const
noexcept
{
if
(
parent
->
IsRoot
())
if
(
parent
.
IsRoot
())
return
uri
;
else
{
const
char
*
path
=
parent
->
GetPath
();
const
char
*
path
=
parent
.
GetPath
();
std
::
string
result
;
result
.
reserve
(
strlen
(
path
)
+
1
+
uri
.
length
());
...
...
@@ -74,8 +74,8 @@ LightSong
Song
::
Export
()
const
noexcept
{
LightSong
dest
(
uri
.
c_str
(),
tag
);
if
(
!
parent
->
IsRoot
())
dest
.
directory
=
parent
->
GetPath
();
if
(
!
parent
.
IsRoot
())
dest
.
directory
=
parent
.
GetPath
();
dest
.
mtime
=
mtime
;
dest
.
start_time
=
start_time
;
dest
.
end_time
=
end_time
;
...
...
src/db/plugins/simple/Song.hxx
View file @
f4d0bd82
...
...
@@ -60,10 +60,9 @@ struct Song {
Tag
tag
;
/**
* The #Directory that contains this song. Must be
* non-nullptr.
* The #Directory that contains this song.
*/
Directory
*
const
parent
;
Directory
&
parent
;
/**
* The time stamp of the last file modification. A negative
...
...
src/db/update/Editor.cxx
View file @
f4d0bd82
...
...
@@ -29,7 +29,7 @@
void
DatabaseEditor
::
DeleteSong
(
Directory
&
dir
,
Song
*
del
)
{
assert
(
del
->
parent
==
&
dir
);
assert
(
&
del
->
parent
==
&
dir
);
/* first, prevent traversers in main task from getting this */
dir
.
RemoveSong
(
del
);
...
...
@@ -65,7 +65,7 @@ DatabaseEditor::ClearDirectory(Directory &directory)
});
directory
.
ForEachSongSafe
([
this
,
&
directory
](
Song
&
song
){
assert
(
song
.
parent
==
&
directory
);
assert
(
&
song
.
parent
==
&
directory
);
DeleteSong
(
directory
,
&
song
);
});
}
...
...
src/db/update/Walk.cxx
View file @
f4d0bd82
...
...
@@ -79,7 +79,7 @@ UpdateWalk::RemoveExcludedFromDirectory(Directory &directory,
});
directory
.
ForEachSongSafe
([
&
](
Song
&
song
){
assert
(
song
.
parent
==
&
directory
);
assert
(
&
song
.
parent
==
&
directory
);
const
auto
name_fs
=
AllocatedPath
::
FromUTF8
(
song
.
uri
.
c_str
());
if
(
name_fs
.
IsNull
()
||
exclude_list
.
Check
(
name_fs
))
{
...
...
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