From 37e4314bf1c44e24277c7e41fca285fce0f2675e Mon Sep 17 00:00:00 2001 From: lukechampine Date: Fri, 10 Jan 2020 16:35:20 -0500 Subject: [PATCH] more compact addChunkChainingValue --- blake3.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/blake3.go b/blake3.go index 7bda520..2455ff8 100644 --- a/blake3.go +++ b/blake3.go @@ -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 // `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. - right := cv for totalChunks&1 == 0 { - // pop + // pop and merge h.stackSize-- - left := h.chainStack[h.stackSize] - // merge - right = parentNode(left, right, h.key, h.flags).chainingValue() + cv = parentNode(h.chainStack[h.stackSize], cv, h.key, h.flags).chainingValue() totalChunks >>= 1 } - h.chainStack[h.stackSize] = right + h.chainStack[h.stackSize] = cv h.stackSize++ }