From 9958aac68a7613a3312fa96dd2f3b29caf17772e Mon Sep 17 00:00:00 2001 From: tersec Date: Thu, 15 Jun 2023 13:13:41 +0000 Subject: [PATCH] remove workaround for unsupported Nim 0.19 and earlier (#200) * remove workaround for unsupported Nim 0.19 and earlier * replace some proc with func --- stew/ranges/stackarrays.nim | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/stew/ranges/stackarrays.nim b/stew/ranges/stackarrays.nim index 2e96460..56d4422 100644 --- a/stew/ranges/stackarrays.nim +++ b/stew/ranges/stackarrays.nim @@ -52,10 +52,10 @@ when defined(windows): else: proc alloca(n: int): pointer {.importc, header: "".} -proc raiseRangeError(s: string) = +func raiseRangeError(s: string) = raise newException(RangeDefect, s) -proc raiseOutOfRange = +func raiseOutOfRange = raiseRangeError "index out of range" template len*(a: StackArray): int = @@ -71,7 +71,7 @@ template `[]`*(a: StackArray, i: int): auto = if i < 0 or i >= a.len: raiseOutOfRange() a.buffer[i] -proc `[]=`*(a: StackArray, i: int, val: a.T) {.inline.} = +func `[]=`*(a: StackArray, i: int, val: a.T) {.inline.} = if i < 0 or i >= a.len: raiseOutOfRange() a.buffer[i] = val @@ -79,7 +79,7 @@ template `[]`*(a: StackArray, i: BackwardsIndex): auto = if int(i) < 1 or int(i) > a.len: raiseOutOfRange() a.buffer[a.len - int(i)] -proc `[]=`*(a: StackArray, i: BackwardsIndex, val: a.T) = +func `[]=`*(a: StackArray, i: BackwardsIndex, val: a.T) = if int(i) < 1 or int(i) > a.len: raiseOutOfRange() a.buffer[a.len - int(i)] = val @@ -121,10 +121,7 @@ template allocStackArrayNoInit*(T: typedesc, size: int): StackArray[T] = allocStackArrayAux(T, size, false) template getBuffer*(a: StackArray): untyped = - when (NimMajor,NimMinor,NimPatch)>=(0,19,9): - a.buffer - else: - a.buffer[] + a.buffer template toOpenArray*(a: StackArray): auto = toOpenArray(a.getBuffer, 0, a.high)