diff options
author | Max Kellermann <max@duempel.org> | 2014-01-11 01:21:54 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-11 01:21:54 +0100 |
commit | 8add78ed5e2efd5421632baf45c3f1d64b43e771 (patch) | |
tree | 83c9d674dd5dbed4b622e597ab3b31b54e80d4bd /src/db | |
parent | 4b3a3d6faaf279a6efbad45616e7b5ebdc5c7a62 (diff) | |
download | mpd-8add78ed5e2efd5421632baf45c3f1d64b43e771.tar.gz mpd-8add78ed5e2efd5421632baf45c3f1d64b43e771.tar.xz mpd-8add78ed5e2efd5421632baf45c3f1d64b43e771.zip |
db/upnp/discovery: convert std::strings to const char *
Reduce bloat.
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/upnp/Discovery.cxx | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/db/upnp/Discovery.cxx b/src/db/upnp/Discovery.cxx index 4065874a6..a94f29d8c 100644 --- a/src/db/upnp/Discovery.cxx +++ b/src/db/upnp/Discovery.cxx @@ -34,25 +34,27 @@ #include <map> // The service type string we are looking for. -static const std::string ContentDirectorySType("urn:schemas-upnp-org:service:ContentDirectory:1"); +static const char *const ContentDirectorySType = "urn:schemas-upnp-org:service:ContentDirectory:1"; // We don't include a version in comparisons, as we are satisfied with // version 1 +gcc_pure static bool -isCDService(const std::string &st) +isCDService(const char *st) { - const std::string::size_type sz(ContentDirectorySType.size()-2); - return !ContentDirectorySType.compare(0, sz, st, 0, sz); + const size_t sz = strlen(ContentDirectorySType) - 2; + return memcmp(ContentDirectorySType, st, sz) == 0; } // The type of device we're asking for in search -static const std::string MediaServerDType("urn:schemas-upnp-org:device:MediaServer:1") ; +static const char *const MediaServerDType = "urn:schemas-upnp-org:device:MediaServer:1"; +gcc_pure static bool -isMSDevice(const std::string &st) +isMSDevice(const char *st) { - const std::string::size_type sz(MediaServerDType.size()-2); - return !MediaServerDType.compare(0, sz, st, 0, sz); + const size_t sz = strlen(MediaServerDType) - 2; + return memcmp(MediaServerDType, st, sz) == 0; } /** @@ -252,7 +254,7 @@ UPnPDeviceDirectory::search() // We search both for device and service just in case. int code = UpnpSearchAsync(lib->getclh(), m_searchTimeout, - ContentDirectorySType.c_str(), lib); + ContentDirectorySType, lib); if (code != UPNP_E_SUCCESS) { error.Format(upnp_domain, code, "UpnpSearchAsync() failed: %s", @@ -261,7 +263,7 @@ UPnPDeviceDirectory::search() } code = UpnpSearchAsync(lib->getclh(), m_searchTimeout, - MediaServerDType.c_str(), lib); + MediaServerDType, lib); if (code != UPNP_E_SUCCESS) { error.Format(upnp_domain, code, "UpnpSearchAsync() failed: %s", @@ -297,7 +299,7 @@ UPnPDeviceDirectory::getDirServices(std::vector<ContentDirectoryService> &out) for (auto dit = contentDirectories.m_directories.begin(); dit != contentDirectories.m_directories.end(); dit++) { for (const auto &service : dit->second.device.services) { - if (isCDService(service.serviceType)) { + if (isCDService(service.serviceType.c_str())) { out.emplace_back(dit->second.device, service); } } |