Skip to content
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

GODRIVER-2536 Return early in replaceErrors. #1076

Merged
merged 1 commit into from Sep 16, 2022
Merged

GODRIVER-2536 Return early in replaceErrors. #1076

merged 1 commit into from Sep 16, 2022

Conversation

benjirewis
Copy link
Contributor

GODRIVER-2536

Returns nil in replaceErrors when err == nil to avoid costly reflection logic below.

Here's a benchmark I used to measure the difference in operations per second. The output from benchstat was:

name             old time/op    new time/op    delta
ReplaceErrors-8    12.2ns ± 1%     2.7ns ± 0%  -78.19%  (p=0.008 n=5+5)

Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

Thanks for the benchmark results! Looks good 👍

@benjirewis benjirewis merged commit 60e3958 into mongodb:master Sep 16, 2022
@benjirewis benjirewis deleted the replaceErrorsNil.2536 branch September 16, 2022 17:38
Julien-Beezeelinx pushed a commit to Julien-Beezeelinx/mongo-go-driver that referenced this pull request Oct 20, 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
3 participants