Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixing mistake in encoding/gob
  • Loading branch information
grantnelson-wf committed Jul 15, 2024
commit edeab09a9ca8e583d07f6c7f3c8403291997a449
7 changes: 3 additions & 4 deletions compiler/natives/src/encoding/gob/gob.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ 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 {
cp = length
}
vs.Set(vs.Slice(0, cp))
v.Set(vs)
vps.Set(vs.Addr())
}
8 changes: 8 additions & 0 deletions compiler/natives/src/encoding/gob/gob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}