Skip to content

Commit

Permalink
fix reaching the max alloc size with the custom gc
Browse files Browse the repository at this point in the history
  • Loading branch information
radkomih committed Aug 31, 2023
1 parent 9b6f9f8 commit 2c2bee9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions fixed_length.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ import (
)

func (value U8) Encode(buffer *bytes.Buffer) {
// do not use value.Bytes() here: https://github.com/LimeChain/goscale/issues/77
encoder := Encoder{Writer: buffer}
encoder.Write(value.Bytes())
encoder.EncodeByte(byte(value))
}

func (value U8) Bytes() []byte {
return []byte{byte(value)}
buf := make([]byte, 1)
buf[0] = byte(value)
return buf
}

func DecodeU8(buffer *bytes.Buffer) U8 {
Expand Down Expand Up @@ -135,9 +138,9 @@ func DecodeI64(buffer *bytes.Buffer) I64 {
return I64(DecodeU64(buffer))
}

func (u U128) Encode(buffer *bytes.Buffer) {
u[0].Encode(buffer)
u[1].Encode(buffer)
func (value U128) Encode(buffer *bytes.Buffer) {
value[0].Encode(buffer)
value[1].Encode(buffer)
}

func (u U128) Bytes() []byte {
Expand Down

0 comments on commit 2c2bee9

Please sign in to comment.