diff options
author | Araq <rumpf_a@web.de> | 2017-08-04 21:27:14 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-08-04 21:27:14 +0200 |
commit | 153441db1da722c0fb5c210a09d9a83a5d1b9656 (patch) | |
tree | 7d06996b07b3c578c724ef5def3dea6f1bb524f3 /compiler/ccgtrav.nim | |
parent | d60da4f8f08676f51fa6dffece35bfe8800d4ae6 (diff) | |
download | Nim-153441db1da722c0fb5c210a09d9a83a5d1b9656.tar.gz |
codegen: do not produce empty loops; speeds up debug builds tremendously on Windows
Diffstat (limited to 'compiler/ccgtrav.nim')
-rw-r--r-- | compiler/ccgtrav.nim | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/compiler/ccgtrav.nim b/compiler/ccgtrav.nim index 982f88cbd..fa228ff04 100644 --- a/compiler/ccgtrav.nim +++ b/compiler/ccgtrav.nim @@ -72,10 +72,16 @@ proc genTraverseProc(c: var TTraversalClosure, accessor: Rope, typ: PType) = let arraySize = lengthOrd(typ.sons[0]) var i: TLoc getTemp(p, getSysType(tyInt), i) + let oldCode = p.s(cpsStmts) linefmt(p, cpsStmts, "for ($1 = 0; $1 < $2; $1++) {$n", i.r, arraySize.rope) + let oldLen = p.s(cpsStmts).len genTraverseProc(c, rfmt(nil, "$1[$2]", accessor, i.r), typ.sons[1]) - lineF(p, cpsStmts, "}$n", []) + if p.s(cpsStmts).len == oldLen: + # do not emit dummy long loops for faster debug builds: + p.s(cpsStmts) = oldCode + else: + lineF(p, cpsStmts, "}$n", []) of tyObject: for i in countup(0, sonsLen(typ) - 1): var x = typ.sons[i] @@ -99,10 +105,16 @@ proc genTraverseProcSeq(c: var TTraversalClosure, accessor: Rope, typ: PType) = assert typ.kind == tySequence var i: TLoc getTemp(p, getSysType(tyInt), i) + let oldCode = p.s(cpsStmts) lineF(p, cpsStmts, "for ($1 = 0; $1 < $2->$3; $1++) {$n", [i.r, accessor, rope(if c.p.module.compileToCpp: "len" else: "Sup.len")]) + let oldLen = p.s(cpsStmts).len genTraverseProc(c, "$1->data[$2]" % [accessor, i.r], typ.sons[0]) - lineF(p, cpsStmts, "}$n", []) + if p.s(cpsStmts).len == oldLen: + # do not emit dummy long loops for faster debug builds: + p.s(cpsStmts) = oldCode + else: + lineF(p, cpsStmts, "}$n", []) proc genTraverseProc(m: BModule, origTyp: PType; sig: SigHash; reason: TTypeInfoReason): Rope = |