From 9d3d4fc7341f8da31a1786f8521a31efa6f75202 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 5 Jul 2019 18:05:04 +0200 Subject: [PATCH] util/CharUtil: add `noexcept` --- src/util/CharUtil.hxx | 26 +++++++++++++------------- src/util/WCharUtil.hxx | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/util/CharUtil.hxx b/src/util/CharUtil.hxx index c1e1c1489..2dc7e34eb 100644 --- a/src/util/CharUtil.hxx +++ b/src/util/CharUtil.hxx @@ -35,25 +35,25 @@ #endif constexpr bool -IsASCII(const unsigned char ch) +IsASCII(const unsigned char ch) noexcept { return ch < 0x80; } constexpr bool -IsASCII(const char ch) +IsASCII(const char ch) noexcept { return IsASCII((unsigned char)ch); } constexpr bool -IsWhitespaceOrNull(const char ch) +IsWhitespaceOrNull(const char ch) noexcept { return (unsigned char)ch <= 0x20; } constexpr bool -IsWhitespaceNotNull(const char ch) +IsWhitespaceNotNull(const char ch) noexcept { return ch > 0 && ch <= 0x20; } @@ -65,43 +65,43 @@ IsWhitespaceNotNull(const char ch) * matches. */ constexpr bool -IsWhitespaceFast(const char ch) +IsWhitespaceFast(const char ch) noexcept { return IsWhitespaceOrNull(ch); } constexpr bool -IsPrintableASCII(char ch) +IsPrintableASCII(char ch) noexcept { return (signed char)ch >= 0x20; } constexpr bool -IsDigitASCII(char ch) +IsDigitASCII(char ch) noexcept { return ch >= '0' && ch <= '9'; } constexpr bool -IsUpperAlphaASCII(char ch) +IsUpperAlphaASCII(char ch) noexcept { return ch >= 'A' && ch <= 'Z'; } constexpr bool -IsLowerAlphaASCII(char ch) +IsLowerAlphaASCII(char ch) noexcept { return ch >= 'a' && ch <= 'z'; } constexpr bool -IsAlphaASCII(char ch) +IsAlphaASCII(char ch) noexcept { return IsUpperAlphaASCII(ch) || IsLowerAlphaASCII(ch); } constexpr bool -IsAlphaNumericASCII(char ch) +IsAlphaNumericASCII(char ch) noexcept { return IsAlphaASCII(ch) || IsDigitASCII(ch); } @@ -111,7 +111,7 @@ IsAlphaNumericASCII(char ch) * Unlike toupper(), it ignores the system locale. */ constexpr char -ToUpperASCII(char ch) +ToUpperASCII(char ch) noexcept { return ch >= 'a' && ch <= 'z' ? (ch - ('a' - 'A')) @@ -123,7 +123,7 @@ ToUpperASCII(char ch) * Unlike tolower(), it ignores the system locale. */ constexpr char -ToLowerASCII(char ch) +ToLowerASCII(char ch) noexcept { return ch >= 'A' && ch <= 'Z' ? (ch + ('a' - 'A')) diff --git a/src/util/WCharUtil.hxx b/src/util/WCharUtil.hxx index cc1f6dac2..fed907eb7 100644 --- a/src/util/WCharUtil.hxx +++ b/src/util/WCharUtil.hxx @@ -33,19 +33,19 @@ #include constexpr bool -IsASCII(const wchar_t ch) +IsASCII(const wchar_t ch) noexcept { return (ch & ~0x7f) == 0; } constexpr bool -IsWhitespaceOrNull(const wchar_t ch) +IsWhitespaceOrNull(const wchar_t ch) noexcept { return (unsigned)ch <= 0x20; } constexpr bool -IsWhitespaceNotNull(const wchar_t ch) +IsWhitespaceNotNull(const wchar_t ch) noexcept { return ch > 0 && ch <= 0x20; } @@ -57,43 +57,43 @@ IsWhitespaceNotNull(const wchar_t ch) * matches. */ constexpr bool -IsWhitespaceFast(const wchar_t ch) +IsWhitespaceFast(const wchar_t ch) noexcept { return IsWhitespaceOrNull(ch); } constexpr bool -IsPrintableASCII(wchar_t ch) +IsPrintableASCII(wchar_t ch) noexcept { return IsASCII(ch) && ch >= 0x20; } constexpr bool -IsDigitASCII(wchar_t ch) +IsDigitASCII(wchar_t ch) noexcept { return ch >= '0' && ch <= '9'; } constexpr bool -IsUpperAlphaASCII(wchar_t ch) +IsUpperAlphaASCII(wchar_t ch) noexcept { return ch >= 'A' && ch <= 'Z'; } constexpr bool -IsLowerAlphaASCII(wchar_t ch) +IsLowerAlphaASCII(wchar_t ch) noexcept { return ch >= 'a' && ch <= 'z'; } constexpr bool -IsAlphaASCII(wchar_t ch) +IsAlphaASCII(wchar_t ch) noexcept { return IsUpperAlphaASCII(ch) || IsLowerAlphaASCII(ch); } constexpr bool -IsAlphaNumericASCII(wchar_t ch) +IsAlphaNumericASCII(wchar_t ch) noexcept { return IsAlphaASCII(ch) || IsDigitASCII(ch); } @@ -103,7 +103,7 @@ IsAlphaNumericASCII(wchar_t ch) * Unlike toupper(), it ignores the system locale. */ constexpr wchar_t -ToUpperASCII(wchar_t ch) +ToUpperASCII(wchar_t ch) noexcept { return ch >= 'a' && ch <= 'z' ? (ch - ('a' - 'A')) @@ -115,7 +115,7 @@ ToUpperASCII(wchar_t ch) * Unlike tolower(), it ignores the system locale. */ constexpr wchar_t -ToLowerASCII(wchar_t ch) +ToLowerASCII(wchar_t ch) noexcept { return ch >= 'A' && ch <= 'Z' ? (ch + ('a' - 'A'))