Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenberry committed Jul 18, 2024
1 parent 219c9b0 commit c1ca41d
Show file tree
Hide file tree
Showing 5 changed files with 5,826 additions and 717 deletions.
46 changes: 23 additions & 23 deletions include/glaze/json/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ namespace glz
ctx.error = error_code::unexpected_end;
return;
}

uint64_t chunk;
std::memcpy(&chunk, it, 8);
const uint64_t test_chars = has_quote(chunk);
Expand All @@ -707,14 +707,14 @@ namespace glz

auto n = size_t(it - start);
value.resize(n + string_padding_bytes);

auto* p = value.data();

while (true) {
if (start >= it) {
break;
}

std::memcpy(p, start, 8);
uint64_t swar;
std::memcpy(&swar, p, 8);
Expand All @@ -737,7 +737,7 @@ namespace glz
if (start >= it) {
break;
}

if ((*start & 0b11100000) == 0) [[unlikely]] {
ctx.error = error_code::syntax_error;
return;
Expand Down Expand Up @@ -768,7 +768,7 @@ namespace glz
--n;
}
}

value.resize(n);
++it;
}
Expand Down Expand Up @@ -808,15 +808,15 @@ namespace glz

if constexpr (not Opts.raw_string) {
static constexpr auto string_padding_bytes = 8;

if (size_t(end - it) >= 8) {
auto start = it;
const auto end8 = end - 8;
while (true) {
if (it >= end8) [[unlikely]] {
break;
}

uint64_t chunk;
std::memcpy(&chunk, it, 8);
const uint64_t test_chars = has_quote(chunk);
Expand All @@ -836,13 +836,13 @@ namespace glz
it += 8;
}
}

while (it[-1] == '\\') [[unlikely]] {
// if we ended on an escape character then we need to rewind
// because we lost our context
--it;
}

for (; it < end; ++it) {
if (*it == '"') {
auto* prev = it - 1;
Expand All @@ -854,24 +854,24 @@ namespace glz
}
}
}

ctx.error = error_code::unexpected_end;
return;
continue_decode:

continue_decode:

const auto available_padding = size_t(end - it);
auto n = size_t(it - start);
if (available_padding >= 8) [[likely]] {
value.resize(n + string_padding_bytes);

auto* p = value.data();

while (true) {
if (start >= it) {
break;
}

std::memcpy(p, start, 8);
uint64_t swar;
std::memcpy(&swar, p, 8);
Expand All @@ -894,7 +894,7 @@ namespace glz
if (start >= it) {
break;
}

if ((*start & 0b11100000) == 0) [[unlikely]] {
ctx.error = error_code::syntax_error;
return;
Expand Down Expand Up @@ -925,15 +925,15 @@ namespace glz
--n;
}
}

value.resize(n);
++it;
}
else {
// For large inputs this case of running out of buffer is very rare
value.resize(n);
auto* p = value.data();

it = start;
while (it < end) [[likely]] {
*p = *it;
Expand Down Expand Up @@ -966,17 +966,17 @@ namespace glz
++p;
}
}

ctx.error = error_code::unexpected_end;
}
}
else {
// For short strings

std::array<char, 8> buffer{};

auto* p = buffer.data();

while (it < end) [[likely]] {
*p = *it;
if (*it == '"') {
Expand Down Expand Up @@ -1008,7 +1008,7 @@ namespace glz
++p;
}
}

ctx.error = error_code::unexpected_end;
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/glaze/json/write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ namespace glz
c += 8;
continue;
}

const auto length = (countr_zero(next) >> 3);
c += length;
data += length;
Expand Down
43 changes: 22 additions & 21 deletions include/glaze/util/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ namespace glz::detail
}

template <class Char>
[[nodiscard]] GLZ_ALWAYS_INLINE uint32_t handle_unicode_code_point(const Char*& it, Char*& dst, const Char* end) noexcept
[[nodiscard]] GLZ_ALWAYS_INLINE uint32_t handle_unicode_code_point(const Char*& it, Char*& dst,
const Char* end) noexcept
{
using namespace unicode;

Expand Down Expand Up @@ -521,26 +522,26 @@ namespace glz::detail
return (chunk & repeat_byte8(0b11110000u));
}

#define GLZ_SKIP_WS(RETURN) \
if constexpr (!Opts.minified) { \
if constexpr (Opts.comments) { \
while (whitespace_comment_table[uint8_t(*it)]) { \
if (*it == '/') [[unlikely]] { \
skip_comment(ctx, it, end); \
if (bool(ctx.error)) [[unlikely]] { \
return RETURN; \
} \
} \
else [[likely]] { \
++it; \
} \
} \
} \
else { \
while (whitespace_table[uint8_t(*it)]) { \
++it; \
} \
} \
#define GLZ_SKIP_WS(RETURN) \
if constexpr (!Opts.minified) { \
if constexpr (Opts.comments) { \
while (whitespace_comment_table[uint8_t(*it)]) { \
if (*it == '/') [[unlikely]] { \
skip_comment(ctx, it, end); \
if (bool(ctx.error)) [[unlikely]] { \
return RETURN; \
} \
} \
else [[likely]] { \
++it; \
} \
} \
} \
else { \
while (whitespace_table[uint8_t(*it)]) { \
++it; \
} \
} \
}

// skip whitespace
Expand Down
Loading

0 comments on commit c1ca41d

Please sign in to comment.