-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: embed "noCopy" for bytes.Buffer and strings.Builder #25907
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
Comments
Unfortunately, that will give the |
Note that |
@dsnet sorry, my mistake, the @ianlancetaylor I didn't notice that |
In what cases does it not work? Even if we add |
If a Builder is copied before it writes anything, then the dynamic check doesn't work. On the other hand, I don't understand what safety the dynamic check guarantees. I couldn't imagine any type unsafety caused by copying a Builder. It looks there are only some unexpected results from the String method calls. |
It's OK to copy a The dynamic check is there to ensure that the |
Actually adding a As described in cmd/vet/README, vet checks should be for problems that are correctness errors, frequent, and where the vet check can be precise. I guess that a small |
OK, get it. How about change the type of the |
Using a pointer instead of a slice would normally require an additional allocation, which would be unfortunate. |
Yes, changing the field to a pointer also hurts the performance. Looks this issue is not very valuable, so I will close it. |
Some new gophers may make mistakes by copying
bytes.Buffer
andstrings.Builder
values.Embed a noCopy will let vet find such mistakes.
The text was updated successfully, but these errors were encountered: