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
74842fd6
Commit
74842fd6
authored
Jan 10, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/upnp: getprop() returns const char *
Return the return value, instead returning it in a reference parameter. Reduces bloat by reducing unnecessary std::string usage.
parent
f23b47ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
21 deletions
+19
-21
UpnpDatabasePlugin.cxx
src/db/UpnpDatabasePlugin.cxx
+16
-16
Object.hxx
src/db/upnp/Object.hxx
+3
-5
No files found.
src/db/UpnpDatabasePlugin.cxx
View file @
74842fd6
...
...
@@ -294,24 +294,24 @@ upnpDurationToSeconds(const std::string &duration)
static
Song
*
upnpItemToSong
(
const
UPnPDirObject
&
dirent
,
const
char
*
uri
)
{
std
::
string
url
(
uri
);
if
(
url
.
empty
())
dirent
.
getprop
(
"url"
,
url
);
if
(
*
uri
==
0
)
uri
=
dirent
.
getprop
(
"url"
);
Song
*
s
=
Song
::
NewFile
(
url
.
c_str
(),
nullptr
);
std
::
string
sprop
(
"0:0:0"
);
dirent
.
getprop
(
"duration"
,
sprop
);
int
seconds
=
upnpDurationToSeconds
(
sprop
);
Song
*
s
=
Song
::
NewFile
(
uri
,
nullptr
);
TagBuilder
tag
;
tag
.
SetTime
(
seconds
);
const
char
*
duration
=
dirent
.
getprop
(
"duration"
);
if
(
duration
!=
nullptr
)
tag
.
SetTime
(
upnpDurationToSeconds
(
duration
));
tag
.
AddItem
(
TAG_TITLE
,
titleToPathElt
(
dirent
.
m_title
).
c_str
());
for
(
auto
i
=
upnp_tags
;
i
->
name
!=
nullptr
;
++
i
)
if
(
dirent
.
getprop
(
i
->
name
,
sprop
))
tag
.
AddItem
(
i
->
type
,
sprop
.
c_str
());
for
(
auto
i
=
upnp_tags
;
i
->
name
!=
nullptr
;
++
i
)
{
const
char
*
value
=
dirent
.
getprop
(
i
->
name
);
if
(
value
!=
nullptr
)
tag
.
AddItem
(
i
->
type
,
value
);
}
s
->
tag
=
tag
.
CommitNew
();
return
s
;
...
...
@@ -378,11 +378,11 @@ getTagValue(UPnPDirObject& dirent, TagType tag,
if
(
name
==
nullptr
)
return
false
;
std
::
string
propvalue
;
dirent
.
getprop
(
name
,
propvalue
);
if
(
propvalue
.
empty
())
const
char
*
value
=
dirent
.
getprop
(
name
);
if
(
value
==
nullptr
)
return
false
;
tagvalue
=
propvalue
;
tagvalue
=
value
;
return
true
;
}
...
...
src/db/upnp/Object.hxx
View file @
74842fd6
...
...
@@ -56,13 +56,11 @@ public:
* @param[out] value
* @return true if found.
*/
bool
getprop
(
const
std
::
string
&
name
,
std
::
string
&
value
)
const
{
const
char
*
getprop
(
const
char
*
name
)
const
{
auto
it
=
m_props
.
find
(
name
);
if
(
it
==
m_props
.
end
())
return
false
;
value
=
it
->
second
;
return
true
;
return
nullptr
;
return
it
->
second
.
c_str
();
}
void
clear
()
...
...
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