*: 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

@@ -27,7 +27,8 @@
#include <string.h>
char *
CopyString(char *gcc_restrict dest, const char *gcc_restrict src, size_t size)
CopyString(char *gcc_restrict dest, const char *gcc_restrict src,
size_t size) noexcept
{
size_t length = strlen(src);
if (length >= size)
@@ -39,7 +40,7 @@ CopyString(char *gcc_restrict dest, const char *gcc_restrict src, size_t size)
}
const char *
StripLeft(const char *p)
StripLeft(const char *p) noexcept
{
while (IsWhitespaceNotNull(*p))
++p;
@@ -48,7 +49,7 @@ StripLeft(const char *p)
}
const char *
StripLeft(const char *p, const char *end)
StripLeft(const char *p, const char *end) noexcept
{
while (p < end && IsWhitespaceOrNull(*p))
++p;
@@ -57,7 +58,7 @@ StripLeft(const char *p, const char *end)
}
const char *
StripRight(const char *p, const char *end)
StripRight(const char *p, const char *end) noexcept
{
while (end > p && IsWhitespaceOrNull(end[-1]))
--end;
@@ -66,7 +67,7 @@ StripRight(const char *p, const char *end)
}
size_t
StripRight(const char *p, size_t length)
StripRight(const char *p, size_t length) noexcept
{
while (length > 0 && IsWhitespaceOrNull(p[length - 1]))
--length;
@@ -75,7 +76,7 @@ StripRight(const char *p, size_t length)
}
void
StripRight(char *p)
StripRight(char *p) noexcept
{
size_t old_length = strlen(p);
size_t new_length = StripRight(p, old_length);
@@ -83,7 +84,7 @@ StripRight(char *p)
}
char *
Strip(char *p)
Strip(char *p) noexcept
{
p = StripLeft(p);
StripRight(p);
@@ -91,7 +92,8 @@ Strip(char *p)
}
bool
StringArrayContainsCase(const char *const*haystack, const char *needle)
StringArrayContainsCase(const char *const*haystack,
const char *needle) noexcept
{
assert(haystack != nullptr);
assert(needle != nullptr);
@@ -104,7 +106,7 @@ StringArrayContainsCase(const char *const*haystack, const char *needle)
}
void
ToUpperASCII(char *dest, const char *src, size_t size)
ToUpperASCII(char *dest, const char *src, size_t size) noexcept
{
assert(dest != nullptr);
assert(src != nullptr);