diff --git a/.github/workflows/check_amalgamation.yml b/.github/workflows/check_amalgamation.yml index 5a7efb07f..649d26907 100644 --- a/.github/workflows/check_amalgamation.yml +++ b/.github/workflows/check_amalgamation.yml @@ -67,7 +67,9 @@ jobs: python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json.json -s . python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_fwd.json -s . - python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_view.json -s . + # the configuration of json_view.hpp comes with the pull request until + # it is on develop; the tool itself is still develop's + python3 $TOOL_DIR/amalgamate.py -c $MAIN_DIR/tools/amalgamate/config_json_view.json -s . # the header list of the Bazel "json" target must match the files in include/ cmake -P cmake/scripts/gen_bazel_build_file.cmake diff --git a/include/nlohmann/detail/view/builder.hpp b/include/nlohmann/detail/view/builder.hpp index 2e0151b31..8393b9c8d 100644 --- a/include/nlohmann/detail/view/builder.hpp +++ b/include/nlohmann/detail/view/builder.hpp @@ -195,8 +195,9 @@ class builder { const std::uint64_t done = static_cast(at - b) + 1; const std::uint64_t guess = static_cast(n) * static_cast(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(guess + (guess / 4) + 64), n + (n / 2) + 64)); + doc.reserve((std::max)(static_cast(grown), n + (n / 2) + 64)); return doc.tape; } diff --git a/include/nlohmann/detail/view/pointer.hpp b/include/nlohmann/detail/view/pointer.hpp index 2c7b1e4db..d2ac497d7 100644 --- a/include/nlohmann/detail/view/pointer.hpp +++ b/include/nlohmann/detail/view/pointer.hpp @@ -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::numeric_limits::max)())) + if (v >= (std::numeric_limits::max)()) // (std::size_t converts to std::uint64_t implicitly) { return index_status::too_large; } diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index f3cd5cd48..95a31af58 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -739,8 +739,9 @@ class builder { const std::uint64_t done = static_cast(at - b) + 1; const std::uint64_t guess = static_cast(n) * static_cast(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(guess + (guess / 4) + 64), n + (n / 2) + 64)); + doc.reserve((std::max)(static_cast(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::numeric_limits::max)())) + if (v >= (std::numeric_limits::max)()) // (std::size_t converts to std::uint64_t implicitly) { return index_status::too_large; }