Skip to content

minor: minor raw BSON perf and API improvements #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 4, 2022

Conversation

patrickfreed
Copy link
Contributor

This PR implements a few minor performance and API improvements to the raw BSON API that I noticed while benchmarking it / using it in the driver.

  • RawDocumentBuf::append accepts and impl AsRef<str> for the key instead of an impl Into<String>
    • this allows us to avoid an allocation when we have string reference types
    • we can't really move a string into our buffer anyways, so for owned strings there isn't any perf penalty here
    • this also applies to the FromIterator implementation for RawDocumentBuf
  • exposed all fields of RawJavaScriptCodeWithScopeRef and RawRegexRef
    • this is in line with other similar types
    • the getters were removed as part of this

@patrickfreed patrickfreed merged commit f4ce826 into mongodb:master Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants