diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-02-13 16:31:33 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-02-13 16:32:23 -0800 |
commit | 336f758d59a8a0411c745d744a1e5c3294eaf78a (patch) | |
tree | deb292095d163d762f6401e013171bd9eaa7852d /tools/go_marshal/gomarshal/util.go | |
parent | 16308b9dc1d3709fadebb9f56a71f2ab81771c8a (diff) |
Ensure the marshalled object doesn't escape.
Add new Marshallable interface methods CopyIn/CopyOut, which can be directly
called on the marshalled object, avoiding an interface indirection. Such
indirections are problematic because they always cause the marshalled object to
escape.
PiperOrigin-RevId: 295028010
Diffstat (limited to 'tools/go_marshal/gomarshal/util.go')
-rw-r--r-- | tools/go_marshal/gomarshal/util.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/go_marshal/gomarshal/util.go b/tools/go_marshal/gomarshal/util.go index 967537abf..3d86935b4 100644 --- a/tools/go_marshal/gomarshal/util.go +++ b/tools/go_marshal/gomarshal/util.go @@ -219,6 +219,11 @@ type sourceBuffer struct { b bytes.Buffer } +func (b *sourceBuffer) reset() { + b.indent = 0 + b.b.Reset() +} + func (b *sourceBuffer) incIndent() { b.indent++ } |