stackitem: reusable serialization context

We serialize items a lot and this allows to avoid a number of allocations.
This commit is contained in:
Roman Khimov 2022-05-31 20:10:20 +03:00
parent 3d4076ca36
commit c3d989ebda
13 changed files with 111 additions and 42 deletions

View file

@ -24,7 +24,11 @@ func getConvertibleFromDAO(id int32, d *dao.Simple, key []byte, conv stackitem.C
}
func putConvertibleToDAO(id int32, d *dao.Simple, key []byte, conv stackitem.Convertible) error {
data, err := stackitem.SerializeConvertible(conv)
item, err := conv.ToStackItem()
if err != nil {
return err
}
data, err := d.GetItemCtx().Serialize(item, false)
if err != nil {
return err
}