From 3c6dfdb27f2acb814efc66111052881feda67a1a Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Wed, 6 Dec 2023 13:05:26 -0500 Subject: [PATCH] WIP --- bson/marshal.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bson/marshal.go b/bson/marshal.go index 6c50d7e3eb..09fd9e7b46 100644 --- a/bson/marshal.go +++ b/bson/marshal.go @@ -78,9 +78,10 @@ func MarshalValue(val interface{}) (bsontype.Type, []byte, error) { // Deprecated: Using a custom registry to marshal individual BSON values will not be supported in Go // Driver 2.0. func MarshalValueWithRegistry(r *bsoncodec.Registry, val interface{}) (bsontype.Type, []byte, error) { - sw := new(bsonrw.SliceWriter) - *sw = make([]byte, 0) - vwFlusher := bvwPool.GetAtModeElement(sw) + // sw := new(bsonrw.SliceWriter) + // *sw = make([]byte, 0) + var sw bsonrw.SliceWriter + vwFlusher := bvwPool.GetAtModeElement(&sw) // get an Encoder and encode the value enc := encPool.Get().(*Encoder) @@ -97,8 +98,8 @@ func MarshalValueWithRegistry(r *bsoncodec.Registry, val interface{}) (bsontype. if err := vwFlusher.Flush(); err != nil { return 0, nil, err } - buffer := *sw - return bsontype.Type(buffer[0]), buffer[2:], nil + // buffer := *sw + return bsontype.Type(sw[0]), sw[2:], nil } // MarshalValueWithContext returns the BSON encoding of val using EncodeContext ec.