mirror of
https://github.com/vbatts/merkle.git
synced 2024-11-13 18:48:37 +00:00
stream: reduce allocs in Reset()
improvement: ``` benchmark old ns/op new ns/op delta BenchmarkHash8Bytes 21137 12201 -42.28% BenchmarkHash1K 27235 14842 -45.50% BenchmarkHash8K 38630 29034 -24.84% benchmark old MB/s new MB/s speedup BenchmarkHash8Bytes 0.38 0.66 1.74x BenchmarkHash1K 37.60 68.99 1.83x BenchmarkHash8K 212.06 282.15 1.33x benchmark old allocs new allocs delta BenchmarkHash8Bytes 10 9 -10.00% BenchmarkHash1K 10 9 -10.00% BenchmarkHash8K 9 8 -11.11% benchmark old bytes new bytes delta BenchmarkHash8Bytes 16712 8520 -49.02% BenchmarkHash1K 17728 9536 -46.21% BenchmarkHash8K 16704 8512 -49.04% ```
This commit is contained in:
parent
c5700a9f0d
commit
fa4337c370
1 changed files with 3 additions and 2 deletions
|
@ -49,8 +49,9 @@ type merkleHash struct {
|
|||
}
|
||||
|
||||
func (mh *merkleHash) Reset() {
|
||||
mh1 := newMerkleHash(mh.hm, mh.blockSize)
|
||||
*mh = *mh1
|
||||
mh.tree = &Tree{Nodes: []*Node{}, BlockLength: mh.blockSize}
|
||||
mh.lastBlockLen = 0
|
||||
mh.partialLastNode = false
|
||||
}
|
||||
|
||||
func (mh merkleHash) Nodes() []*Node {
|
||||
|
|
Loading…
Reference in a new issue