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
0696cac5
Commit
0696cac5
authored
Jan 18, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/upnp/Discovery: eliminate full copy in getServer()
parent
0c2485e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
Discovery.cxx
src/db/upnp/Discovery.cxx
+16
-6
Discovery.hxx
src/db/upnp/Discovery.hxx
+1
-3
No files found.
src/db/upnp/Discovery.cxx
View file @
0696cac5
...
...
@@ -262,14 +262,24 @@ UPnPDeviceDirectory::getServer(const char *friendlyName,
ContentDirectoryService
&
server
,
Error
&
error
)
{
std
::
vector
<
ContentDirectoryService
>
ds
;
if
(
!
getDirServices
(
ds
,
error
))
// Has locking, do it before our own lock
if
(
!
expireDevices
(
error
))
return
false
;
for
(
const
auto
&
i
:
ds
)
{
if
(
strcmp
(
friendlyName
,
i
.
getFriendlyName
())
==
0
)
{
server
=
i
;
return
true
;
const
ScopeLock
protect
(
mutex
);
for
(
const
auto
&
i
:
directories
)
{
const
auto
&
device
=
i
.
second
.
device
;
if
(
device
.
friendlyName
!=
friendlyName
)
continue
;
for
(
const
auto
&
service
:
device
.
services
)
{
if
(
isCDService
(
service
.
serviceType
.
c_str
()))
{
server
=
ContentDirectoryService
(
device
,
service
);
return
true
;
}
}
}
...
...
src/db/upnp/Discovery.hxx
View file @
0696cac5
...
...
@@ -107,9 +107,7 @@ public:
bool
getDirServices
(
std
::
vector
<
ContentDirectoryService
>
&
,
Error
&
);
/**
* Get server by friendly name. It's a bit wasteful to copy
* all servers for this, we could directly walk the list. Otoh
* there isn't going to be millions...
* Get server by friendly name.
*/
bool
getServer
(
const
char
*
friendlyName
,
ContentDirectoryService
&
server
,
...
...
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