codegen: do not produce empty loops; speeds up debug builds tremendously on Windows
This commit is contained in:
parent
d60da4f8f0
commit
153441db1d
1 changed files with 14 additions and 2 deletions
|
|
@ -72,10 +72,16 @@ proc genTraverseProc(c: var TTraversalClosure, accessor: Rope, typ: PType) =
|
||||||
let arraySize = lengthOrd(typ.sons[0])
|
let arraySize = lengthOrd(typ.sons[0])
|
||||||
var i: TLoc
|
var i: TLoc
|
||||||
getTemp(p, getSysType(tyInt), i)
|
getTemp(p, getSysType(tyInt), i)
|
||||||
|
let oldCode = p.s(cpsStmts)
|
||||||
linefmt(p, cpsStmts, "for ($1 = 0; $1 < $2; $1++) {$n",
|
linefmt(p, cpsStmts, "for ($1 = 0; $1 < $2; $1++) {$n",
|
||||||
i.r, arraySize.rope)
|
i.r, arraySize.rope)
|
||||||
|
let oldLen = p.s(cpsStmts).len
|
||||||
genTraverseProc(c, rfmt(nil, "$1[$2]", accessor, i.r), typ.sons[1])
|
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:
|
of tyObject:
|
||||||
for i in countup(0, sonsLen(typ) - 1):
|
for i in countup(0, sonsLen(typ) - 1):
|
||||||
var x = typ.sons[i]
|
var x = typ.sons[i]
|
||||||
|
|
@ -99,10 +105,16 @@ proc genTraverseProcSeq(c: var TTraversalClosure, accessor: Rope, typ: PType) =
|
||||||
assert typ.kind == tySequence
|
assert typ.kind == tySequence
|
||||||
var i: TLoc
|
var i: TLoc
|
||||||
getTemp(p, getSysType(tyInt), i)
|
getTemp(p, getSysType(tyInt), i)
|
||||||
|
let oldCode = p.s(cpsStmts)
|
||||||
lineF(p, cpsStmts, "for ($1 = 0; $1 < $2->$3; $1++) {$n",
|
lineF(p, cpsStmts, "for ($1 = 0; $1 < $2->$3; $1++) {$n",
|
||||||
[i.r, accessor, rope(if c.p.module.compileToCpp: "len" else: "Sup.len")])
|
[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])
|
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;
|
proc genTraverseProc(m: BModule, origTyp: PType; sig: SigHash;
|
||||||
reason: TTypeInfoReason): Rope =
|
reason: TTypeInfoReason): Rope =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue