Commit 0f7a0b04 authored by Rosen Penev's avatar Rosen Penev

replace loop with find_if

loop is wrong anyway. It's missing a break; Signed-off-by: 's avatarRosen Penev <rosenp@gmail.com>
parent bedcf1cc
...@@ -258,12 +258,8 @@ ContentDirectoryService::getMetadata(UpnpClient_Handle hdl, ...@@ -258,12 +258,8 @@ ContentDirectoryService::getMetadata(UpnpClient_Handle hdl,
if (code != UPNP_E_SUCCESS) if (code != UPNP_E_SUCCESS)
throw FormatRuntimeError("UpnpSendAction() failed: %s", throw FormatRuntimeError("UpnpSendAction() failed: %s",
UpnpGetErrorMessage(code)); UpnpGetErrorMessage(code));
const char *p = ""; auto it = std::find_if(responseData.begin(), responseData.end(), [](auto&& entry){ return entry.first == "Result"; });
for (const auto &entry : responseData) { const char *p = it != responseData.end() ? it->second.c_str() : "";
if (entry.first == "Result") {
p = entry.second.c_str();
}
}
UPnPDirContent dirbuf; UPnPDirContent dirbuf;
dirbuf.Parse(p); dirbuf.Parse(p);
return dirbuf; return dirbuf;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment