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:
Dave Collins 2013-11-06 16:38:51 -06:00
parent 63cc0851e5
commit 1a1f93865f

View file

@ -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
} }