Remove three unnecessary bitmasks
This commit is contained in:
parent
8a872927e8
commit
bdfe29c14b
@ -10344,20 +10344,20 @@ class basic_json
|
||||
else if (codepoint <= 0x7ff)
|
||||
{
|
||||
// 2-byte characters: 110xxxxx 10xxxxxx
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xC0 | (codepoint >> 6)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
|
||||
}
|
||||
else if (codepoint <= 0xffff)
|
||||
{
|
||||
// 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xE0 | (codepoint >> 12)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
|
||||
}
|
||||
else if (codepoint <= 0x10ffff)
|
||||
{
|
||||
// 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xF0 | (codepoint >> 18)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
|
||||
|
||||
@ -10344,20 +10344,20 @@ class basic_json
|
||||
else if (codepoint <= 0x7ff)
|
||||
{
|
||||
// 2-byte characters: 110xxxxx 10xxxxxx
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xC0 | (codepoint >> 6)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
|
||||
}
|
||||
else if (codepoint <= 0xffff)
|
||||
{
|
||||
// 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xE0 | (codepoint >> 12)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
|
||||
}
|
||||
else if (codepoint <= 0x10ffff)
|
||||
{
|
||||
// 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0xF0 | (codepoint >> 18)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
|
||||
result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
|
||||
|
||||
@ -44,16 +44,16 @@ void from_json(const json&, pod) noexcept;
|
||||
void from_json(const json&, pod_bis);
|
||||
static json j;
|
||||
|
||||
static_assert(noexcept(json{}), "");
|
||||
static_assert(noexcept(json {}), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, 2)), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, 2.5)), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, true)), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, test{})), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, pod{})), "");
|
||||
static_assert(not noexcept(nlohmann::to_json(j, pod_bis{})), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, test {})), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, pod {})), "");
|
||||
static_assert(not noexcept(nlohmann::to_json(j, pod_bis {})), "");
|
||||
static_assert(noexcept(json(2)), "");
|
||||
static_assert(noexcept(json(test{})), "");
|
||||
static_assert(noexcept(json(pod{})), "");
|
||||
static_assert(noexcept(json(test {})), "");
|
||||
static_assert(noexcept(json(pod {})), "");
|
||||
static_assert(noexcept(j.get<pod>()), "");
|
||||
static_assert(not noexcept(j.get<pod_bis>()), "");
|
||||
static_assert(noexcept(json(pod{})), "");
|
||||
static_assert(noexcept(json(pod {})), "");
|
||||
|
||||
@ -584,7 +584,7 @@ struct pod_serializer
|
||||
std::is_pod<U>::value and std::is_class<U>::value, int>::type = 0>
|
||||
static void to_json(BasicJsonType& j, const T& t) noexcept
|
||||
{
|
||||
auto bytes = static_cast< const unsigned char*>(static_cast<const void*>(&t));
|
||||
auto bytes = static_cast<const unsigned char*>(static_cast<const void*>(&t));
|
||||
std::uint64_t value = bytes[0];
|
||||
for (auto i = 1; i < 8; ++i)
|
||||
value |= std::uint64_t{bytes[i]} << 8 * i;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user