- Notifications
You must be signed in to change notification settings - Fork921
chore: remove unnecessary redeclarations in for loops#18440
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
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.
Thanks for doing this! I checked and as far as I can tell this should all be safe. If we wanted to be super-safe, we'd just do the ones in*_test.go
and leave the rest till after code freeze.
There are still a few straggling comments left that can also probably be removed.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
40fd4ac
tobf077d3
Comparesorry about that, didn't expect anyone to look so quickly. just cleaned the diff up a bunch. |
johnstcn left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
All of these loopvar instances look safe to remove.
EDIT: for an abundance of safety, I'd prefer if weonly did this for*_test.go
and left the rest alone.
// When we assign the non-pointer to a | ||
// variable it loses the reference. | ||
replica:=replica |
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.
This is the only instance I'm slightly wary of, but the new behaviour seems to be as intended here. It was originally added in#4596 to avoid a test race.
by my count, only 14 of the 214 files this touchesaren't tests.
this language change was very well documented. all this does is remove redundant copies, since |
e98caae
toef8ddee
Comparefae30a0
intomainUh oh!
There was an error while loading.Please reload this page.
disclaimer: I asked claude 4 to do this little bit of cleanup.
I noticed we still have a bunch of these, but these kinds of re-declarations are no longer necessary now that we live in a post go 1.22 world. not a huge change, but didn't take claude very long. :p