From 681b399e2a0a64303ee4c09c0bb780334c0e99da Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Fri, 22 May 2020 10:31:19 +0200 Subject: [PATCH] avoid memory alloc when padding (#1058) also avoid stack state copy in test --- beacon_chain/ssz.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_chain/ssz.nim b/beacon_chain/ssz.nim index 46f3e8e4d..c6f8db332 100644 --- a/beacon_chain/ssz.nim +++ b/beacon_chain/ssz.nim @@ -306,7 +306,7 @@ func mergeBranches(existing: Eth2Digest, newData: openarray[byte]): Eth2Digest = let paddingBytes = bytesPerChunk - newData.len if paddingBytes > 0: trs "USING ", paddingBytes, " PADDING BYTES" - h.update zeroChunk[0 ..< paddingBytes] + h.update zeroChunk.toOpenArray(0, paddingBytes - 1) trs "HASH RESULT ", result template mergeBranches(a, b: Eth2Digest): Eth2Digest =