*: implement EncodeBinary with pointer receivers where appropriate
Everywhere except ParamType (which is just a byte), reduce copying things around for no real reason.
This commit is contained in:
parent
7e371588a7
commit
5b6c5af704
5 changed files with 6 additions and 5 deletions
|
@ -160,7 +160,7 @@ func (p *Payload) SetHeight(h uint32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinaryUnsigned writes payload to w excluding signature.
|
// EncodeBinaryUnsigned writes payload to w excluding signature.
|
||||||
func (p Payload) EncodeBinaryUnsigned(w *io.BinWriter) {
|
func (p *Payload) EncodeBinaryUnsigned(w *io.BinWriter) {
|
||||||
w.WriteLE(p.version)
|
w.WriteLE(p.version)
|
||||||
w.WriteBytes(p.prevHash[:])
|
w.WriteBytes(p.prevHash[:])
|
||||||
w.WriteLE(p.height)
|
w.WriteLE(p.height)
|
||||||
|
|
|
@ -140,7 +140,7 @@ func (u *UnspentBalance) DecodeBinary(r *io.BinReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinary implements io.Serializable interface.
|
// EncodeBinary implements io.Serializable interface.
|
||||||
func (u UnspentBalance) EncodeBinary(w *io.BinWriter) {
|
func (u *UnspentBalance) EncodeBinary(w *io.BinWriter) {
|
||||||
u.Tx.EncodeBinary(w)
|
u.Tx.EncodeBinary(w)
|
||||||
w.WriteLE(u.Index)
|
w.WriteLE(u.Index)
|
||||||
w.WriteLE(u.Value)
|
w.WriteLE(u.Value)
|
||||||
|
|
|
@ -115,7 +115,8 @@ func (b *Block) Trim() ([]byte, error) {
|
||||||
|
|
||||||
buf.WriteVarUint(uint64(len(b.Transactions)))
|
buf.WriteVarUint(uint64(len(b.Transactions)))
|
||||||
for _, tx := range b.Transactions {
|
for _, tx := range b.Transactions {
|
||||||
tx.Hash().EncodeBinary(buf.BinWriter)
|
h := tx.Hash()
|
||||||
|
h.EncodeBinary(buf.BinWriter)
|
||||||
}
|
}
|
||||||
if buf.Err != nil {
|
if buf.Err != nil {
|
||||||
return nil, buf.Err
|
return nil, buf.Err
|
||||||
|
|
|
@ -56,7 +56,7 @@ func getAppExecResultFromStore(s storage.Store, hash util.Uint256) (*AppExecResu
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinary implements the Serializable interface.
|
// EncodeBinary implements the Serializable interface.
|
||||||
func (ne NotificationEvent) EncodeBinary(w *io.BinWriter) {
|
func (ne *NotificationEvent) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteBytes(ne.ScriptHash[:])
|
w.WriteBytes(ne.ScriptHash[:])
|
||||||
vm.EncodeBinaryStackItem(ne.Item, w)
|
vm.EncodeBinaryStackItem(ne.Item, w)
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ func (u Uint256) MarshalJSON() ([]byte, error) {
|
||||||
func (u Uint256) CompareTo(other Uint256) int { return bytes.Compare(u[:], other[:]) }
|
func (u Uint256) CompareTo(other Uint256) int { return bytes.Compare(u[:], other[:]) }
|
||||||
|
|
||||||
// EncodeBinary implements io.Serializable interface.
|
// EncodeBinary implements io.Serializable interface.
|
||||||
func (u Uint256) EncodeBinary(w *io.BinWriter) {
|
func (u *Uint256) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteBytes(u[:])
|
w.WriteBytes(u[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue