KEMBAR78
Minor BJData fixes by falbrechtskirchinger · Pull Request #3637 · nlohmann/json · GitHub
Skip to content

Conversation

falbrechtskirchinger
Copy link
Contributor

These are the previously discussed minor fixes to the BJData binary_reader code.

  • Replace the std::vector/std::map lookup tables with std::arrays.
    This is meant to be an optimization (mostly avoiding unnecessary, repeated heap allocations). Whether std::lower_bound() is actually faster than std::find/std::find_if in this scenario is unknown.

  • Replace string_t::npos with binary_reader::npos.

@falbrechtskirchinger falbrechtskirchinger force-pushed the bjdata-fixes branch 2 times, most recently from 0d4255d to 79e9357 Compare July 31, 2022 18:54
@coveralls
Copy link

coveralls commented Jul 31, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling 98ef5b5 on falbrechtskirchinger:bjdata-fixes into df98ca2 on nlohmann:develop.

@falbrechtskirchinger
Copy link
Contributor Author

falbrechtskirchinger commented Aug 2, 2022

Wow! This improves performance parsing a 136M document by 0.3%. This was truly worth it! 🤣

(It still avoids heap allocations, though.)

@falbrechtskirchinger falbrechtskirchinger force-pushed the bjdata-fixes branch 2 times, most recently from 8b66859 to b0f6dcd Compare August 2, 2022 07:35
@falbrechtskirchinger
Copy link
Contributor Author

Looks good to me.

Copy link
Owner

@nlohmann nlohmann left a comment

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 the aspect: binary formats BSON, CBOR, MessagePack, UBJSON label Aug 2, 2022
@nlohmann nlohmann added this to the Release 3.11.2 milestone Aug 3, 2022
@nlohmann nlohmann merged commit 3224202 into nlohmann:develop Aug 3, 2022
@falbrechtskirchinger falbrechtskirchinger deleted the bjdata-fixes branch August 3, 2022 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aspect: binary formats BSON, CBOR, MessagePack, UBJSON

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants