Merge branch 'json-view/14-view-compare' into json-view/14b-view-float-layout

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-29 23:11:04 +02:00
3 changed files with 6 additions and 4 deletions

View File

@@ -195,8 +195,9 @@ class builder
{
const std::uint64_t done = static_cast<std::uint64_t>(at - b) + 1;
const std::uint64_t guess = static_cast<std::uint64_t>(n) * static_cast<std::uint64_t>(e - b + 1) / done;
const std::uint64_t grown = guess + (guess / 4) + 64; // a variable: GCC calls a cast of the sum useless where std::uint64_t is std::size_t
doc.tape_size = n;
doc.reserve((std::max)(static_cast<std::size_t>(guess + (guess / 4) + 64), n + (n / 2) + 64));
doc.reserve((std::max)(static_cast<std::size_t>(grown), n + (n / 2) + 64));
return doc.tape;
}

View File

@@ -69,7 +69,7 @@ index_status array_index(const StringType& s, std::size_t& idx) noexcept
}
v = (v * 10) + d;
}
if (v >= static_cast<std::uint64_t>((std::numeric_limits<std::size_t>::max)()))
if (v >= (std::numeric_limits<std::size_t>::max)()) // (std::size_t converts to std::uint64_t implicitly)
{
return index_status::too_large;
}

View File

@@ -739,8 +739,9 @@ class builder
{
const std::uint64_t done = static_cast<std::uint64_t>(at - b) + 1;
const std::uint64_t guess = static_cast<std::uint64_t>(n) * static_cast<std::uint64_t>(e - b + 1) / done;
const std::uint64_t grown = guess + (guess / 4) + 64; // a variable: GCC calls a cast of the sum useless where std::uint64_t is std::size_t
doc.tape_size = n;
doc.reserve((std::max)(static_cast<std::size_t>(guess + (guess / 4) + 64), n + (n / 2) + 64));
doc.reserve((std::max)(static_cast<std::size_t>(grown), n + (n / 2) + 64));
return doc.tape;
}
@@ -2885,7 +2886,7 @@ index_status array_index(const StringType& s, std::size_t& idx) noexcept
}
v = (v * 10) + d;
}
if (v >= static_cast<std::uint64_t>((std::numeric_limits<std::size_t>::max)()))
if (v >= (std::numeric_limits<std::size_t>::max)()) // (std::size_t converts to std::uint64_t implicitly)
{
return index_status::too_large;
}