From 437fcd93fd3509cbd477887e2c69e1d677371b62 Mon Sep 17 00:00:00 2001 From: Nicholas Wiersma Date: Sun, 5 Nov 2023 07:03:32 +0200 Subject: [PATCH] docs: clarify the pointer used (#323) --- codec_record.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codec_record.go b/codec_record.go index dd2edfd7..86295f20 100644 --- a/codec_record.go +++ b/codec_record.go @@ -176,7 +176,6 @@ func encoderOfStruct(cfg *frozenConfig, schema Schema, typ reflect2.Type) ValEnc if defaultType.LikePtr() { defaultEncoder = &onePtrEncoder{defaultEncoder} } - fields = append(fields, &structFieldEncoder{ defaultPtr: reflect2.PtrOf(def), encoder: defaultEncoder, @@ -332,6 +331,8 @@ type recordMapEncoder struct { func (e *recordMapEncoder) Encode(ptr unsafe.Pointer, w *Writer) { for _, field := range e.fields { + // The first property of mapEncoderField is the name, so a pointer + // to field is a pointer to the name. valPtr := e.mapType.UnsafeGetIndex(ptr, reflect2.PtrOf(field)) if valPtr == nil { // Missing required field