Optimize readVarString.

Before:

BenchmarkReadVarStr4     1000000              1698 ns/op
BenchmarkReadVarStr10    1000000              1812 ns/op

After:

BenchmarkReadVarStr4     2000000               853 ns/op
BenchmarkReadVarStr10    5000000               712 ns/op

This is part ef the ongoing effort to optimize serialization as noted in
conformal/btcd#27.
This commit is contained in:
Dave Collins 2013-11-05 23:33:21 -06:00
parent b830e2ddf3
commit 4002051a22

View file

@ -167,7 +167,7 @@ func readVarString(r io.Reader, pver uint32) (string, error) {
}
buf := make([]byte, count)
err = readElement(r, buf)
_, err = io.ReadFull(r, buf)
if err != nil {
return "", err
}