From 7e747d11c66405f08cc7c69e5afc18348663275e Mon Sep 17 00:00:00 2001 From: Clyybber Date: Thu, 28 Nov 2019 17:13:04 +0100 Subject: Cosmetic compiler cleanup (#12718) * Cleanup compiler code base * Unify add calls * Unify len invocations * Unify range operators * Fix oversight * Remove {.procvar.} pragma * initCandidate -> newCandidate where reasonable * Unify safeLen calls --- compiler/semparallel.nim | 81 ++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 41 deletions(-) (limited to 'compiler/semparallel.nim') diff --git a/compiler/semparallel.nim b/compiler/semparallel.nim index 724c868b7..62264ab40 100644 --- a/compiler/semparallel.nim +++ b/compiler/semparallel.nim @@ -92,10 +92,9 @@ proc lookupSlot(c: AnalysisCtx; s: PSym): int = proc getSlot(c: var AnalysisCtx; v: PSym): ptr MonotonicVar = let s = lookupSlot(c, v) if s >= 0: return addr(c.locals[s]) - let L = c.locals.len - c.locals.setLen(L+1) - c.locals[L].v = v - return addr(c.locals[L]) + c.locals.setLen(c.locals.len+1) + c.locals[^1].v = v + return addr(c.locals[^1]) proc gatherArgs(c: var AnalysisCtx; n: PNode) = for i in 0..= 0 and c.locals[s].stride != nil: localError(c.graph.config, n.info, "invalid usage of counter after increment") else: - for i in 0 ..< n.safeLen: checkLocal(c, n.sons[i]) + for i in 0..= 0 and c.locals[s].stride != nil: result = c.locals[s].stride.intVal else: - for i in 0 ..< n.safeLen: result += stride(c, n.sons[i]) + for i in 0.. 0: result = shallowCopy(n) - for i in 0 ..< n.len: result.sons[i] = subStride(c, n.sons[i]) + for i in 0..= 0 and m >= 0): @@ -255,7 +254,7 @@ proc checkSlicesAreDisjoint(c: var AnalysisCtx) = proc analyse(c: var AnalysisCtx; n: PNode) proc analyseSons(c: var AnalysisCtx; n: PNode) = - for i in 0 ..< safeLen(n): analyse(c, n[i]) + for i in 0.. 1: - addFact(c.guards, canon(branch.sons[0], c.guards.o)) - for i in 0 ..< branch.len: - analyse(c, branch.sons[i]) + addFact(c.guards, canon(branch[0], c.guards.o)) + for i in 0.. 0: result = shallowCopy(n) - for i in 0 ..< n.len: - result.sons[i] = transformSlices(g, n.sons[i]) + for i in 0..