Skip to content

fix: clarify cloneSlice comment to explain shallow vs deep copy semantics#1710

Open
alexchenai wants to merge 1 commit intomiekg:masterfrom
alexchenai:fix/cloneslice-comment
Open

fix: clarify cloneSlice comment to explain shallow vs deep copy semantics#1710
alexchenai wants to merge 1 commit intomiekg:masterfrom
alexchenai:fix/cloneslice-comment

Conversation

@alexchenai
Copy link
Copy Markdown

Summary

  • Fixes deep-copy bug or confusion in the comments? #1709 — the cloneSlice comment said "shallow copy" which was confusing since it's used in Copy() which advertises deep-copy semantics
  • Updated the comment to explain that while the slice elements are not deep-copied (shallow copy), for slices of value types (e.g. []byte as used by net.IP), this effectively produces a deep copy
  • No behavior change, comment-only fix

Test plan

  • No code changes, only a doc comment update
  • Verified the new comment accurately describes the function's behavior

🤖 Generated with Claude Code

…tics

The previous comment simply stated "shallow copy" which was confusing
given that cloneSlice is used to implement deep-copy functions (e.g.
Copy). The new comment explains that while the slice elements are not
deep-copied (making it a shallow copy), for slices of value types like
[]byte this effectively produces a deep copy.

Fixes miekg#1709

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

deep-copy bug or confusion in the comments?

1 participant