Add restrict pragma for readUintBE and toByteArrayBE

This commit is contained in:
mratsim 2018-05-08 15:47:32 +02:00
parent 8cd48fc0e9
commit 0209af26a2
1 changed files with 4 additions and 2 deletions

View File

@ -304,7 +304,8 @@ func readUintBE*[bits: static[int]](ba: openarray[byte]): Stuint[bits] =
const N = bits div 8 const N = bits div 8
assert(ba.len == N) assert(ba.len == N)
let r_ptr = cast[ptr array[N, byte]](result.addr) {.pragma: restrict, codegenDecl: "$# __restrict $#".}
let r_ptr {.restrict.} = cast[ptr array[N, byte]](result.addr)
for i, val in ba: for i, val in ba:
when system.cpuEndian == bigEndian: when system.cpuEndian == bigEndian:
# TODO: due to https://github.com/status-im/nim-stint/issues/38 # TODO: due to https://github.com/status-im/nim-stint/issues/38
@ -325,6 +326,7 @@ func toByteArrayBE*[bits: static[int]](n: StUint[bits]): array[bits div 8, byte]
when system.cpuEndian == bigEndian: when system.cpuEndian == bigEndian:
result = cast[type result](n) result = cast[type result](n)
else: else:
let n_ptr = cast[ptr array[N, byte]](n.unsafeAddr) {.pragma: restrict, codegenDecl: "$# __restrict $#".}
let n_ptr {.restrict.} = cast[ptr array[N, byte]](n.unsafeAddr)
for i in 0 ..< N: for i in 0 ..< N:
result[N-1 - i] = n_ptr[i] result[N-1 - i] = n_ptr[i]