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
|
@ -80,12 +80,12 @@ func (pt ParamType) MarshalJSON() ([]byte, error) {
|
|||
|
||||
// EncodeBinary implements io.Serializable interface.
|
||||
func (pt ParamType) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteBytes([]byte{byte(pt)})
|
||||
w.WriteByte(byte(pt))
|
||||
}
|
||||
|
||||
// DecodeBinary implements io.Serializable interface.
|
||||
func (pt *ParamType) DecodeBinary(r *io.BinReader) {
|
||||
r.ReadLE(pt)
|
||||
*pt = ParamType(r.ReadByte())
|
||||
}
|
||||
|
||||
// NewParameter returns a Parameter with proper initialized Value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue