From edeab09a9ca8e583d07f6c7f3c8403291997a449 Mon Sep 17 00:00:00 2001 From: Grant Nelson Date: Mon, 15 Jul 2024 14:34:07 -0600 Subject: [PATCH] Fixing mistake in encoding/gob --- compiler/natives/src/encoding/gob/gob.go | 7 +++---- compiler/natives/src/encoding/gob/gob_test.go | 8 ++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/natives/src/encoding/gob/gob.go b/compiler/natives/src/encoding/gob/gob.go index f21315171..244f72ed7 100644 --- a/compiler/natives/src/encoding/gob/gob.go +++ b/compiler/natives/src/encoding/gob/gob.go @@ -26,9 +26,9 @@ func (x *atomicEncEnginePointer) Store(val *encEngine) { x.v = val } // temporarily replacement of growSlice[E any] for go1.20 without generics. func growSlice(v reflect.Value, ps any, length int) { - vps := reflect.ValueOf(ps) - vs := vps.Elem() - zero := reflect.Zero(vs.Elem().Type()) + vps := reflect.ValueOf(ps) // *[]E + vs := vps.Elem() // []E + zero := reflect.Zero(vs.Type().Elem()) vs.Set(reflect.Append(vs, zero)) cp := vs.Cap() if cp > length { @@ -36,5 +36,4 @@ func growSlice(v reflect.Value, ps any, length int) { } vs.Set(vs.Slice(0, cp)) v.Set(vs) - vps.Set(vs.Addr()) } diff --git a/compiler/natives/src/encoding/gob/gob_test.go b/compiler/natives/src/encoding/gob/gob_test.go index 823b572ac..a2f303ab6 100644 --- a/compiler/natives/src/encoding/gob/gob_test.go +++ b/compiler/natives/src/encoding/gob/gob_test.go @@ -105,3 +105,11 @@ func TestTypeRace(t *testing.T) { // cannot succeed when nosync is used. t.Skip("using nosync") } + +func TestCountEncodeMallocs(t *testing.T) { + t.Skip("testing.AllocsPerRun not supported in GopherJS") +} + +func TestCountDecodeMallocs(t *testing.T) { + t.Skip("testing.AllocsPerRun not supported in GopherJS") +}