Skip to content

Cosmetic cleanups in the BSON writer (stale comment, inconsistent signature) - #5313

Merged
nlohmann merged 1 commit into
nlohmann:developfrom
banaboi:cleanup/cosmetic-cleanups-bson-writer
Jul 27, 2026
Merged

nlohmann merged 1 commit into
nlohmann:developfrom
banaboi:cleanup/cosmetic-cleanups-bson-writer

Conversation

@banaboi

@banaboi banaboi commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Two non-functional cleanups in include/nlohmann/detail/output/binary_writer.hpp:

  1. Remove stale // boolean comment in write_bson_entry_header. That function
    writes the header for every BSON element type, not just booleans. The comment is
    left over from when the code was boolean-specific.

  2. Change write_bson_unsigned to take std::uint64_t instead of const BasicJsonType&.
    It reached into j.m_data.m_value.number_unsigned three times, while every sibling
    (write_bson_boolean, write_bson_double, write_bson_integer, write_bson_string)
    takes the plain value. The BasicJsonType parameter was only needed as diagnostic
    context for the out_of_range.407 throw that Making Code cleaner #4286 removed, so it no longer earns
    its keep. The call site now reads like its neighbours.

While there, fixed the doc comment on the adjacent calc_bson_unsigned_size, which still
referred to "the unsigned integer in @a j" despite already taking a value parameter.

No behaviour change.

Closes #5312

  • The changes are described in detail, both the what and why.
  • If applicable, an existing issue is referenced.
  • The Code coverage remained at 100%. A test case for every new line of code.
  • If applicable, the documentation is updated.
  • The source code is amalgamated by running make amalgamate.

Read the Contribution Guidelines for detailed information.

Signed-off-by: banaboi <lukebanicevic@gmail.com>
@banaboi
banaboi requested a review from nlohmann as a code owner July 26, 2026 22:18
@banaboi banaboi changed the title adding cleanups to bson writer Cosmetic cleanups in the BSON writer (stale comment, inconsistent signature) Jul 26, 2026

@nlohmann nlohmann left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@nlohmann nlohmann added this to the Release 3.13.0 milestone Jul 26, 2026
@nlohmann nlohmann added the 🚀 ready to merge Ready to merge - just waiting for CI to complete. label Jul 26, 2026
@github-actions github-actions Bot added the M label Jul 26, 2026
@nlohmann
nlohmann merged commit 8ec98e2 into nlohmann:develop Jul 27, 2026
156 checks passed
jwnimmer-tri pushed a commit to jwnimmer-tri/json that referenced this pull request Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M 🚀 ready to merge Ready to merge - just waiting for CI to complete.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cosmetic cleanups in the BSON writer (stale comment, inconsistent signature)

2 participants