Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: remove unnecessary redeclarations in for loops (part 2)#18593

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

Merged
aslilac merged 4 commits intomainfromlilac/go-122-range-fix-all
Jun 26, 2025

Conversation

aslilac
Copy link
Member

Now that we're post code-freeze, let's go forth with the other half of this cleanup.

Comment on lines -411 to -413
// When we assign the non-pointer to a
// variable it loses the reference.
replica:=replica
Copy link
MemberAuthor

@aslilacaslilacJun 25, 2025
edited
Loading

Choose a reason for hiding this comment

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

@johnstcn you called out this one as potentially being a concern, but I think there are already two "copies" happening here that make this safe

  • it gets copied from the slice to thereplica variable by the loop
  • it gets copied from thereplica variable to the argument value as part of theappend call on the next line

ie. go does nothave "references", it has pointers and values. you're either copying a pointer or you're copying the whole value.

here's a go playground that hopefully instills confidencehttps://go.dev/play/p/MfFltxQepYE

johnstcn reacted with thumbs up emoji
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

Thanks@aslilac!

@aslilacaslilac merged commit09cc906 intomainJun 26, 2025
39 checks passed
@aslilacaslilac deleted the lilac/go-122-range-fix-all branchJune 26, 2025 18:28
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 26, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

@johnstcnjohnstcnjohnstcn approved these changes

Assignees

@aslilacaslilac

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@aslilac@dannykopping@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp