Optimize writeTxIn.
Before: BenchmarkWriteTxIn 5000000 422 ns/op After: BenchmarkWriteTxIn 5000000 389 ns/op This is part of the ongoing effort to optimize serialization as noted in conformal/btcd#27.
This commit is contained in:
parent
63cc0851e5
commit
1a1f93865f
1 changed files with 4 additions and 3 deletions
7
msgtx.go
7
msgtx.go
|
@ -504,13 +504,14 @@ func writeTxIn(w io.Writer, pver uint32, version uint32, ti *TxIn) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b := []byte(ti.SignatureScript)
|
_, err = w.Write(ti.SignatureScript)
|
||||||
_, err = w.Write(b)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = writeElement(w, &ti.Sequence)
|
buf := make([]byte, 4)
|
||||||
|
binary.LittleEndian.PutUint32(buf, ti.Sequence)
|
||||||
|
_, err = w.Write(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue