Skip to content

Commit 9958aac

Browse files
authored
remove workaround for unsupported Nim 0.19 and earlier (#200)
* remove workaround for unsupported Nim 0.19 and earlier * replace some proc with func
1 parent 65ce220 commit 9958aac

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

stew/ranges/stackarrays.nim

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ when defined(windows):
5252
else:
5353
proc alloca(n: int): pointer {.importc, header: "<alloca.h>".}
5454

55-
proc raiseRangeError(s: string) =
55+
func raiseRangeError(s: string) =
5656
raise newException(RangeDefect, s)
5757

58-
proc raiseOutOfRange =
58+
func raiseOutOfRange =
5959
raiseRangeError "index out of range"
6060

6161
template len*(a: StackArray): int =
@@ -71,15 +71,15 @@ template `[]`*(a: StackArray, i: int): auto =
7171
if i < 0 or i >= a.len: raiseOutOfRange()
7272
a.buffer[i]
7373

74-
proc `[]=`*(a: StackArray, i: int, val: a.T) {.inline.} =
74+
func `[]=`*(a: StackArray, i: int, val: a.T) {.inline.} =
7575
if i < 0 or i >= a.len: raiseOutOfRange()
7676
a.buffer[i] = val
7777

7878
template `[]`*(a: StackArray, i: BackwardsIndex): auto =
7979
if int(i) < 1 or int(i) > a.len: raiseOutOfRange()
8080
a.buffer[a.len - int(i)]
8181

82-
proc `[]=`*(a: StackArray, i: BackwardsIndex, val: a.T) =
82+
func `[]=`*(a: StackArray, i: BackwardsIndex, val: a.T) =
8383
if int(i) < 1 or int(i) > a.len: raiseOutOfRange()
8484
a.buffer[a.len - int(i)] = val
8585

@@ -121,10 +121,7 @@ template allocStackArrayNoInit*(T: typedesc, size: int): StackArray[T] =
121121
allocStackArrayAux(T, size, false)
122122

123123
template getBuffer*(a: StackArray): untyped =
124-
when (NimMajor,NimMinor,NimPatch)>=(0,19,9):
125-
a.buffer
126-
else:
127-
a.buffer[]
124+
a.buffer
128125

129126
template toOpenArray*(a: StackArray): auto =
130127
toOpenArray(a.getBuffer, 0, a.high)

0 commit comments

Comments
 (0)