Optimize writeVarString.

Before:

BenchmarkWriteVarStr4    1000000              1114 ns/op
BenchmarkWriteVarStr10   1000000              1352 ns/op

After:

BenchmarkWriteVarStr4    5000000               291 ns/op
BenchmarkWriteVarStr10  10000000               248 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:59:40 -06:00
parent fa8f666e8c
commit 8a1828a2d6

View file

@ -181,7 +181,7 @@ func writeVarString(w io.Writer, pver uint32, str string) error {
if err != nil {
return err
}
err = writeElement(w, []byte(str))
_, err = w.Write([]byte(str))
if err != nil {
return err
}