mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-19 15:31:28 +00:00
Optimize cgen.addIndent (#21508)
* Optimize `cgen.addIndent` * Avoid temporaries
This commit is contained in:
committed by
GitHub
parent
c52e44d845
commit
26b7a74a45
@@ -228,8 +228,12 @@ macro ropecg(m: BModule, frmt: static[FormatStr], args: untyped): Rope =
|
||||
result.add newCall(ident"rope", resVar)
|
||||
|
||||
proc addIndent(p: BProc; result: var Rope) =
|
||||
for i in 0..<p.blocks.len:
|
||||
result.add "\t".rope
|
||||
var i = result.len
|
||||
let newLen = i + p.blocks.len
|
||||
result.setLen newLen
|
||||
while i < newLen:
|
||||
result[i] = '\t'
|
||||
inc i
|
||||
|
||||
template appcg(m: BModule, c: var Rope, frmt: FormatStr,
|
||||
args: untyped) =
|
||||
|
||||
Reference in New Issue
Block a user