more replacements for the deprecated '<'

This commit is contained in:
Andreas Rumpf 2017-10-29 08:55:30 +01:00
commit 6a3288a60e
19 changed files with 43 additions and 43 deletions

View file

@ -257,7 +257,7 @@ proc allprefixedAux[T](c: CritBitTree[T], key: string; longestMatch: bool): Node
p = p.child[dir]
if q.byte < key.len: top = p
if not longestMatch:
for i in 0 .. <key.len:
for i in 0 ..< key.len:
if p.key[i] != key[i]: return
result = top

View file

@ -149,7 +149,7 @@ template delImpl() {.dirty.} =
delImplIdx(t, i)
template clearImpl() {.dirty.} =
for i in 0 .. <t.data.len:
for i in 0 ..< t.data.len:
when compiles(t.data[i].hcode): # CountTable records don't contain a hcode
t.data[i].hcode = 0
t.data[i].key = default(type(t.data[i].key))

View file

@ -149,7 +149,7 @@ proc selectWorker(w: ptr Worker; fn: WorkerProc; data: pointer): bool =
proc cleanFlowVars(w: ptr Worker) =
let q = addr(w.q)
acquire(q.lock)
for i in 0 .. <q.len:
for i in 0 ..< q.len:
GC_unref(cast[RootRef](q.data[i]))
#echo "GC_unref"
q.len = 0
@ -543,7 +543,7 @@ proc sync*() =
var toRelease = 0
while true:
var allReady = true
for i in 0 .. <currentPoolSize:
for i in 0 ..< currentPoolSize:
if not allReady: break
allReady = allReady and workersData[i].ready
if allReady: break

View file

@ -22,7 +22,7 @@ proc createProcType(p, b: NimNode): NimNode {.compileTime.} =
case p.kind
of nnkPar:
for i in 0 .. <p.len:
for i in 0 ..< p.len:
let ident = p[i]
var identDefs = newNimNode(nnkIdentDefs)
case ident.kind
@ -77,7 +77,7 @@ macro `=>`*(p, b: untyped): untyped =
if c[0].kind == nnkIdent and c[0].ident == !"->":
var procTy = createProcType(c[1], c[2])
params[0] = procTy[0][0]
for i in 1 .. <procTy[0].len:
for i in 1 ..< procTy[0].len:
params.add(procTy[0][i])
else:
error("Expected proc type (->) got (" & $c[0].ident & ").")
@ -96,7 +96,7 @@ macro `=>`*(p, b: untyped): untyped =
if p[0].kind == nnkIdent and p[0].ident == !"->":
var procTy = createProcType(p[1], p[2])
params[0] = procTy[0][0]
for i in 1 .. <procTy[0].len:
for i in 1 ..< procTy[0].len:
params.add(procTy[0][i])
else:
error("Expected proc type (->) got (" & $p[0].ident & ").")

View file

@ -823,13 +823,13 @@ proc toJson(x: NimNode): NimNode {.compiletime.} =
of nnkBracket: # array
if x.len == 0: return newCall(bindSym"newJArray")
result = newNimNode(nnkBracket)
for i in 0 .. <x.len:
for i in 0 ..< x.len:
result.add(toJson(x[i]))
result = newCall(bindSym"%", result)
of nnkTableConstr: # object
if x.len == 0: return newCall(bindSym"newJObject")
result = newNimNode(nnkTableConstr)
for i in 0 .. <x.len:
for i in 0 ..< x.len:
x[i].expectKind nnkExprColonExpr
result.add newTree(nnkExprColonExpr, x[i][0], toJson(x[i][1]))
result = newCall(bindSym"%", result)
@ -1303,7 +1303,7 @@ else:
case getVarType(x)
of JArray:
result = newJArray()
for i in 0 .. <x.len:
for i in 0 ..< x.len:
result.add(x[i].convertObject())
of JObject:
result = newJObject()
@ -1449,7 +1449,7 @@ proc processElseBranch(recCaseNode, elseBranch, jsonNode, kindType,
# We need to build up a list of conditions from each ``of`` branch so that
# we can then negate it to get ``else``.
var cond = newIdentNode("false")
for i in 1 .. <len(recCaseNode):
for i in 1 ..< len(recCaseNode):
if recCaseNode[i].kind == nnkElse:
break
@ -1511,7 +1511,7 @@ proc processObjField(field, jsonNode: NimNode): seq[NimNode] =
exprColonExpr.add(getEnumCall)
# Iterate through each `of` branch.
for i in 1 .. <field.len:
for i in 1 ..< field.len:
case field[i].kind
of nnkOfBranch:
result.add processOfBranch(field[i], jsonNode, kindType, kindJsonNode)
@ -1640,7 +1640,7 @@ proc createConstructor(typeSym, jsonNode: NimNode): NimNode =
(
var list: `typeSym` = @[];
verifyJsonKind(`jsonNode`, {JArray}, astToStr(`jsonNode`));
for `forLoopI` in 0 .. <`jsonNode`.len: list.add(`constructorNode`);
for `forLoopI` in 0 ..< `jsonNode`.len: list.add(`constructorNode`);
list
)
of "array":
@ -1654,7 +1654,7 @@ proc createConstructor(typeSym, jsonNode: NimNode): NimNode =
(
var list: `typeSym`;
verifyJsonKind(`jsonNode`, {JArray}, astToStr(`jsonNode`));
for `forLoopI` in 0 .. <`jsonNode`.len: list[`forLoopI`] =`constructorNode`;
for `forLoopI` in 0 ..< `jsonNode`.len: list[`forLoopI`] =`constructorNode`;
list
)
@ -1683,7 +1683,7 @@ proc postProcessValue(value: NimNode): NimNode =
result = postProcess(value)
else:
result = value
for i in 0 .. <len(result):
for i in 0 ..< len(result):
result[i] = postProcessValue(result[i])
proc postProcessExprColonExpr(exprColonExpr, resIdent: NimNode): NimNode =

View file

@ -283,7 +283,7 @@ proc to*[T](data: string): T =
loadAny(newStringStream(data), toAny(result), tab)
when not defined(testing) and isMainModule:
template testit(x: expr) = echo($$to[type(x)]($$x))
template testit(x: untyped) = echo($$to[type(x)]($$x))
var x: array[0..4, array[0..4, string]] = [
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],

View file

@ -162,7 +162,7 @@ elif defined(linux):
return @[]
raiseOSError(err)
if evNum == 0: return @[]
for i in 0 .. <evNum:
for i in 0 ..< evNum:
let fd = s.events[i].data.fd.SocketHandle
var evSet: set[Event] = {}
@ -253,7 +253,7 @@ elif defined(macosx) or defined(freebsd) or defined(openbsd) or defined(netbsd):
return @[]
raiseOSError(err)
if evNum == 0: return @[]
for i in 0 .. <evNum:
for i in 0 ..< evNum:
let fd = s.events[i].ident.SocketHandle
var evSet: set[Event] = {}

View file

@ -1199,7 +1199,7 @@ proc unindent*(s: string, count: Natural, padding: string = " "): string
var indentCount = 0
for j in 0..<count.int:
indentCount.inc
if line[j .. j + <padding.len] != padding:
if line[j .. j + padding.len-1] != padding:
indentCount = j
break
result.add(line[indentCount*padding.len .. ^1])
@ -1407,10 +1407,10 @@ proc find*(s, sub: string, start: Natural = 0, last: Natural = 0): int {.noSideE
## Searching is case-sensitive. If `sub` is not in `s`, -1 is returned.
if sub.len > s.len:
return -1
if sub.len == 1:
return find(s, sub[0], start, last)
var a {.noinit.}: SkipTable
initSkipTable(a, sub)
result = find(a, s, sub, start, last)

View file

@ -250,7 +250,7 @@ proc combine*(base: Uri, reference: Uri): Uri =
proc combine*(uris: varargs[Uri]): Uri =
## Combines multiple URIs together.
result = uris[0]
for i in 1 .. <uris.len:
for i in 1 ..< uris.len:
result = combine(result, uris[i])
proc isAbsolute*(uri: Uri): bool =