Optimize readOutPoint.
Before: BenchmarkReadOutPoint 500000 2946 ns/op After: BenchmarkReadOutPoint 5000000 582 ns/op This is part ef the ongoing effort to optimize serialization as noted in conformal/btcd#27.
This commit is contained in:
parent
d63e0dd455
commit
73f4ee623b
1 changed files with 8 additions and 1 deletions
9
msgtx.go
9
msgtx.go
|
@ -417,10 +417,17 @@ func NewMsgTx() *MsgTx {
|
|||
|
||||
// readOutPoint reads the next sequence of bytes from r as an OutPoint.
|
||||
func readOutPoint(r io.Reader, pver uint32, version uint32, op *OutPoint) error {
|
||||
err := readElements(r, &op.Hash, &op.Index)
|
||||
_, err := io.ReadFull(r, op.Hash[:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
buf := make([]byte, 4)
|
||||
_, err = io.ReadFull(r, buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
op.Index = binary.LittleEndian.Uint32(buf)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue