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

use Sync.once opt the lazy init func #522

Merged
merged 1 commit into from
Oct 15, 2020

Conversation

imxyb
Copy link
Contributor

@imxyb imxyb commented Oct 12, 2020

No description provided.

@stevenh
Copy link
Collaborator

stevenh commented Oct 12, 2020

Cleaner but does it result in better performance?

Could you create a benchmark to prove either way?

@imxyb
Copy link
Contributor Author

imxyb commented Oct 12, 2020

Cleaner but does it result in better performance?

Could you create a benchmark to prove either way?

I have used BenchmarkPoolGet to compare, and the performance is almost the same as before. This change can make the code cleaner and more concise

@FZambia
Copy link
Contributor

FZambia commented Oct 12, 2020

btw, sync.Once internally also has a fast path based on the atomic comparison.

@imxyb
Copy link
Contributor Author

imxyb commented Oct 12, 2020

btw, sync.Once internally also has a fast path based on the atomic comparison.

yes, i know, this change is only make the code more cleaner and readable

@stevenh stevenh merged commit 4a33ea0 into gomodule:master Oct 15, 2020
@stevenh
Copy link
Collaborator

stevenh commented Oct 15, 2020

Thanks for confirming.

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