From 198c3cb785282ee4c199680ec2d05381805a6f66 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 11 Dec 2024 15:42:06 -0500 Subject: std: pass bytes.Buffer and strings.Builder by pointer This CL fixes a number of (all true positive) findings of vet's copylock analyzer patched to treat the Bu{ff,uild}er types as non-copyable after first use. This does require imposing an additional indirection between noder.writer and Encoder since the field is embedded by value but its constructor now returns a pointer. Updates golang/go#25907 Updates golang/go#47276 Change-Id: I0b4d77ac12bcecadf06a91709e695365da10766c Reviewed-on: https://go-review.googlesource.com/c/go/+/635339 Reviewed-by: Robert Findley Commit-Queue: Alan Donovan LUCI-TryBot-Result: Go LUCI Auto-Submit: Alan Donovan --- src/internal/pkgbits/encoder.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/internal/pkgbits/encoder.go') diff --git a/src/internal/pkgbits/encoder.go b/src/internal/pkgbits/encoder.go index 1b38469097..5c51642e3c 100644 --- a/src/internal/pkgbits/encoder.go +++ b/src/internal/pkgbits/encoder.go @@ -121,7 +121,7 @@ func (pw *PkgEncoder) StringIdx(s string) RelIndex { // NewEncoder returns an Encoder for a new element within the given // section, and encodes the given SyncMarker as the start of the // element bitstream. -func (pw *PkgEncoder) NewEncoder(k SectionKind, marker SyncMarker) Encoder { +func (pw *PkgEncoder) NewEncoder(k SectionKind, marker SyncMarker) *Encoder { e := pw.NewEncoderRaw(k) e.Sync(marker) return e @@ -131,11 +131,11 @@ func (pw *PkgEncoder) NewEncoder(k SectionKind, marker SyncMarker) Encoder { // section. // // Most callers should use NewEncoder instead. -func (pw *PkgEncoder) NewEncoderRaw(k SectionKind) Encoder { +func (pw *PkgEncoder) NewEncoderRaw(k SectionKind) *Encoder { idx := RelIndex(len(pw.elems[k])) pw.elems[k] = append(pw.elems[k], "") // placeholder - return Encoder{ + return &Encoder{ p: pw, k: k, Idx: idx, -- cgit v1.3-5-g9baa