mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-06 09:55:09 +00:00
io: add type-specific read/write methods
This seriously improves the serialization/deserialization performance for several reasons: * no time spent in `binary` reflection * no memory allocations being made on every read/write * uses fast ReadBytes everywhere it's appropriate It also makes Fixed8 Serializable just for convenience.
This commit is contained in:
parent
89d7f6d26e
commit
54d888ba70
43 changed files with 441 additions and 205 deletions
|
@ -23,7 +23,7 @@ type StateDescriptor struct {
|
|||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (s *StateDescriptor) DecodeBinary(r *io.BinReader) {
|
||||
r.ReadLE(&s.Type)
|
||||
s.Type = DescStateType(r.ReadByte())
|
||||
|
||||
s.Key = r.ReadVarBytes()
|
||||
s.Value = r.ReadVarBytes()
|
||||
|
@ -32,7 +32,7 @@ func (s *StateDescriptor) DecodeBinary(r *io.BinReader) {
|
|||
|
||||
// EncodeBinary implements Serializable interface.
|
||||
func (s *StateDescriptor) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteLE(s.Type)
|
||||
w.WriteByte(byte(s.Type))
|
||||
w.WriteVarBytes(s.Key)
|
||||
w.WriteVarBytes(s.Value)
|
||||
w.WriteString(s.Field)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue