Don't trigger the gcsafe effect when accessing zeroBytesRlp

This commit is contained in:
Zahary Karadjov 2018-06-17 19:56:00 +03:00
parent 2363474e5c
commit 1ac76ba687
1 changed files with 7 additions and 2 deletions

View File

@ -35,8 +35,13 @@ proc rlpFromBytes*(data: BytesRange): Rlp =
result.bytes = data
result.position = 0
let
zeroBytesRlp* = Rlp()
let zeroBytesRlpInst = Rlp()
# We want `zeroBytesRlp` to act as a constant value, but not
# to interfere with the `gcsafe` effect. To achieve this, we
# need an accessor template:
template zeroBytesRlp*: auto = {.gcsafe.}: zeroBytesRlpInst
# XXX: Perhaps this is no longer relevant with `BytesRange`
# having the `shallow` pragma, must be investigated.
proc rlpFromHex*(input: string): Rlp =
doAssert input.len mod 2 == 0,