*: add "noexcept" to many, many function prototypes

This eliminates some overhead, because the compiler doesn't need to
consider these functions throwing.
This commit is contained in:
Max Kellermann
2017-05-08 14:44:49 +02:00
parent ac2e4e593d
commit 71f0ed8b74
272 changed files with 873 additions and 846 deletions

View File

@@ -36,7 +36,7 @@ static constexpr char ContentDirectorySType[] = "urn:schemas-upnp-org:service:Co
// version 1
gcc_pure
static bool
isCDService(const char *st)
isCDService(const char *st) noexcept
{
constexpr size_t sz = sizeof(ContentDirectorySType) - 3;
return memcmp(ContentDirectorySType, st, sz) == 0;
@@ -47,7 +47,7 @@ static constexpr char MediaServerDType[] = "urn:schemas-upnp-org:device:MediaSer
gcc_pure
static bool
isMSDevice(const char *st)
isMSDevice(const char *st) noexcept
{
constexpr size_t sz = sizeof(MediaServerDType) - 3;
return memcmp(MediaServerDType, st, sz) == 0;

View File

@@ -23,7 +23,7 @@
/** Get rid of white space at both ends */
void
trimstring(std::string &s, const char *ws)
trimstring(std::string &s, const char *ws) noexcept
{
auto pos = s.find_first_not_of(ws);
if (pos == std::string::npos) {
@@ -38,14 +38,14 @@ trimstring(std::string &s, const char *ws)
}
static void
path_catslash(std::string &s)
path_catslash(std::string &s) noexcept
{
if (s.empty() || s.back() != '/')
s += '/';
}
std::string
path_getfather(const std::string &s)
path_getfather(const std::string &s) noexcept
{
std::string father = s;
@@ -71,7 +71,7 @@ path_getfather(const std::string &s)
std::list<std::string>
stringToTokens(const std::string &str,
const char delim)
const char delim) noexcept
{
std::list<std::string> tokens;
@@ -105,7 +105,7 @@ stringToTokens(const std::string &str,
template <class T>
bool
csvToStrings(const char *s, T &tokens)
csvToStrings(const char *s, T &tokens) noexcept
{
assert(tokens.empty());
@@ -132,4 +132,4 @@ csvToStrings(const char *s, T &tokens)
}
}
template bool csvToStrings<std::list<std::string>>(const char *, std::list<std::string> &);
template bool csvToStrings<std::list<std::string>>(const char *, std::list<std::string> &) noexcept;

View File

@@ -26,17 +26,17 @@
#include <list>
void
trimstring(std::string &s, const char *ws = " \t\n");
trimstring(std::string &s, const char *ws = " \t\n") noexcept;
std::string
path_getfather(const std::string &s);
path_getfather(const std::string &s) noexcept;
gcc_pure
std::list<std::string>
stringToTokens(const std::string &str, char delim);
stringToTokens(const std::string &str, char delim) noexcept;
template <class T>
bool
csvToStrings(const char *s, T &tokens);
csvToStrings(const char *s, T &tokens) noexcept;
#endif /* _UPNPP_H_X_INCLUDED_ */