Skip to content

GODRIVER-2311 Improve the BSON unmarshal buffer reuse fix to reduce memory allocations. #891

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 1 commit into from
Mar 31, 2022

Conversation

matthewdale
Copy link
Collaborator

@matthewdale matthewdale commented Mar 25, 2022

GODRIVER-2311

As of the fix in #874, we no longer return values that point to the same underlying byte array as the input from bson.Unmarshal. However, the fix copies byte slices that are returned to the caller and byte slices that are copied to byte arrays or converted to other values by the caller. Improve the previous fix to reduce the unnecessary additional copy while maintaining the correct behavior.

Copy link
Contributor

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

Makes sense. The other callers of readBytes already make copies. Thanks for the improvement. LGTM!

@matthewdale matthewdale merged commit 5970415 into mongodb:master Mar 31, 2022
matthewdale added a commit that referenced this pull request Mar 31, 2022
kevinAlbs pushed a commit to kevinAlbs/mongo-go-driver that referenced this pull request Mar 31, 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