Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
refactor: remove
defer
in loop #20223refactor: remove
defer
in loop #20223Changes from all commits
248ad76
306cf5b
7b0116e
e45b71f
023247e
93c36dc
b0c99b4
badd9c5
9995356
b6c8dbe
097384b
e7b1a17
b6a63be
95fc4a7
869ec3e
d819ddd
4543e67
fce217a
fbaef03
953cfac
879999d
e9df29b
8701127
0415482
a737df0
2f0ac3f
5bc9597
076a43f
101706b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your change to move it down below creates an even less likely chance that memIt.Close() due to the large number of branches that could return before it is invoked. You could apply that anonymous closure trick that I showed up above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much appreciated @odeke-em for your insightful review. I have refactored the code, could you kindly take a look. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal preference: break is good and does the job but you can also do
return nil
here already to exit early. There is nothing going on after the loop and a return would make it slightly more readable.