mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-17 00:47:03 +00:00
Remove one-line hash to avoid burnMem.
Remove unnecessary copyMem()s.
This commit is contained in:
parent
2f86bf21c8
commit
6f4c7b775c
@ -36,8 +36,10 @@ func shortLog*(x: Eth2Digest): string =
|
||||
result = ($x)[0..7]
|
||||
|
||||
func eth2hash*(v: openArray[byte]): Eth2Digest =
|
||||
var tmp = Eth2Hash.digest v
|
||||
copyMem(result.data.addr, tmp.addr, sizeof(result))
|
||||
var ctx: Eth2Hash
|
||||
ctx.init()
|
||||
ctx.update(v)
|
||||
result = ctx.finish()
|
||||
|
||||
template withEth2Hash*(body: untyped): Eth2Digest =
|
||||
## This little helper will init the hash function and return the sliced
|
||||
@ -46,9 +48,7 @@ template withEth2Hash*(body: untyped): Eth2Digest =
|
||||
var h {.inject.}: Eth2Hash
|
||||
h.init()
|
||||
body
|
||||
var res: Eth2Digest
|
||||
var tmp = h.finish()
|
||||
copyMem(res.data.addr, tmp.data.addr, sizeof(res))
|
||||
var res = h.finish()
|
||||
res
|
||||
|
||||
func hash*(x: Eth2Digest): Hash =
|
||||
|
Loading…
x
Reference in New Issue
Block a user