From e67783d907b0ae186d794b205cf89c645fe50270 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 1 Jun 2018 10:00:10 +1000 Subject: Mark constant inline Unicode functions as constexpr. --- src/UniConversion.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/UniConversion.h b/src/UniConversion.h index e2be40776..6d257cd8e 100644 --- a/src/UniConversion.h +++ b/src/UniConversion.h @@ -39,11 +39,11 @@ inline int UnicodeFromUTF8(const unsigned char *us) noexcept { } } -inline bool UTF8IsTrailByte(unsigned char ch) noexcept { +inline constexpr bool UTF8IsTrailByte(unsigned char ch) noexcept { return (ch >= 0x80) && (ch < 0xc0); } -inline bool UTF8IsAscii(int ch) noexcept { +inline constexpr bool UTF8IsAscii(int ch) noexcept { return ch < 0x80; } @@ -73,11 +73,11 @@ enum { SURROGATE_TRAIL_FIRST = 0xDC00 }; enum { SURROGATE_TRAIL_LAST = 0xDFFF }; enum { SUPPLEMENTAL_PLANE_FIRST = 0x10000 }; -inline unsigned int UTF16CharLength(wchar_t uch) noexcept { +inline constexpr unsigned int UTF16CharLength(wchar_t uch) noexcept { return ((uch >= SURROGATE_LEAD_FIRST) && (uch <= SURROGATE_LEAD_LAST)) ? 2 : 1; } -inline unsigned int UTF16LengthFromUTF8ByteCount(unsigned int byteCount) noexcept { +inline constexpr unsigned int UTF16LengthFromUTF8ByteCount(unsigned int byteCount) noexcept { return (byteCount < 4) ? 1 : 2; } -- cgit v1.2.3