more compact addChunkChainingValue
This commit is contained in:
parent
4c13e3a25c
commit
37e4314bf1
|
@ -304,16 +304,13 @@ func (h *Hasher) addChunkChainingValue(cv [8]uint32, totalChunks uint64) {
|
||||||
// with the result. After all these merges, push the final value of
|
// with the result. After all these merges, push the final value of
|
||||||
// `cv` onto the stack. The number of completed subtrees is given
|
// `cv` onto the stack. The number of completed subtrees is given
|
||||||
// by the number of trailing 0-bits in the new total number of chunks.
|
// by the number of trailing 0-bits in the new total number of chunks.
|
||||||
right := cv
|
|
||||||
for totalChunks&1 == 0 {
|
for totalChunks&1 == 0 {
|
||||||
// pop
|
// pop and merge
|
||||||
h.stackSize--
|
h.stackSize--
|
||||||
left := h.chainStack[h.stackSize]
|
cv = parentNode(h.chainStack[h.stackSize], cv, h.key, h.flags).chainingValue()
|
||||||
// merge
|
|
||||||
right = parentNode(left, right, h.key, h.flags).chainingValue()
|
|
||||||
totalChunks >>= 1
|
totalChunks >>= 1
|
||||||
}
|
}
|
||||||
h.chainStack[h.stackSize] = right
|
h.chainStack[h.stackSize] = cv
|
||||||
h.stackSize++
|
h.stackSize++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue