mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
use if constexpr instead of a switch statement
The condition is a constant expression, it makes more sense here to use `if constexpr`
This commit is contained in:
parent
37de949d87
commit
c8dbd65ff5
@ -710,15 +710,11 @@ Out Utf<32>::encodeWide(std::uint32_t codepoint, Out output, wchar_t replacement
|
|||||||
// For UCS-2 we need to check if the source characters fits in (UCS-2 is a subset of UCS-4).
|
// For UCS-2 we need to check if the source characters fits in (UCS-2 is a subset of UCS-4).
|
||||||
// For UCS-4 we can do a direct copy (UCS-4 *is* UTF-32).
|
// For UCS-4 we can do a direct copy (UCS-4 *is* UTF-32).
|
||||||
|
|
||||||
switch (sizeof(wchar_t))
|
if constexpr (sizeof(wchar_t) == 4)
|
||||||
{
|
|
||||||
case 4:
|
|
||||||
{
|
{
|
||||||
*output++ = static_cast<wchar_t>(codepoint);
|
*output++ = static_cast<wchar_t>(codepoint);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
if ((codepoint <= 0xFFFF) && ((codepoint < 0xD800) || (codepoint > 0xDFFF)))
|
if ((codepoint <= 0xFFFF) && ((codepoint < 0xD800) || (codepoint > 0xDFFF)))
|
||||||
{
|
{
|
||||||
@ -728,8 +724,6 @@ Out Utf<32>::encodeWide(std::uint32_t codepoint, Out output, wchar_t replacement
|
|||||||
{
|
{
|
||||||
*output++ = replacement;
|
*output++ = replacement;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
Loading…
Reference in New Issue
Block a user