stackitem: serialize integers to the pre-allocated slice

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgeniy Stratonikov 2021-08-03 16:29:21 +03:00
parent 291a29af1e
commit f02d8b4ec4

View file

@ -112,8 +112,11 @@ func (w *serContext) serialize(item Item) error {
} }
case *BigInteger: case *BigInteger:
w.data = append(w.data, byte(IntegerT)) w.data = append(w.data, byte(IntegerT))
data := bigint.ToBytes(t.Value().(*big.Int)) v := t.Value().(*big.Int)
w.appendVarUint(uint64(len(data))) ln := len(w.data)
w.data = append(w.data, 0)
data := bigint.ToPreallocatedBytes(v, w.data[len(w.data):])
w.data[ln] = byte(len(data))
w.data = append(w.data, data...) w.data = append(w.data, data...)
case *Interop: case *Interop:
if w.allowInvalid { if w.allowInvalid {