diff options
author | Araq <rumpf_a@web.de> | 2013-04-07 03:23:15 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-04-07 03:23:15 +0200 |
commit | 0b1630b46c9ab8ba5acb82bc04b998961cef4973 (patch) | |
tree | 53fab7083fade3f55950b2472c0ad60df289f7cd /compiler/evals.nim | |
parent | beb13ecf621f87dea88912c340698459a63f0737 (diff) | |
download | Nim-0b1630b46c9ab8ba5acb82bc04b998961cef4973.tar.gz |
optimized evals.nim a bit
Diffstat (limited to 'compiler/evals.nim')
-rw-r--r-- | compiler/evals.nim | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler/evals.nim b/compiler/evals.nim index a05f96829..66b8de3d0 100644 --- a/compiler/evals.nim +++ b/compiler/evals.nim @@ -294,10 +294,11 @@ proc evalVar(c: PEvalContext, n: PNode): PNode = if a.kind != nkIdentDefs: return raiseCannotEval(c, n.info) # XXX var (x, y) = z support? #assert(a.sons[0].kind == nkSym) can happen for transformed vars - if a.sons[2].kind != nkEmpty: - result = evalAux(c, a.sons[2], {}) - if isSpecial(result): return - else: + if a.sons[2].kind != nkEmpty: + # XXX copyTree could be avoided in some cases + result = evalAux(c, a.sons[2], {}).copyTree + if isSpecial(result): return + else: result = getNullValue(a.sons[0].typ, a.sons[0].info) if a.sons[0].kind == nkSym: var v = a.sons[0].sym @@ -1351,10 +1352,9 @@ proc evalAux(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode = case n.kind of nkSym: result = evalSym(c, n, flags) of nkType..nkNilLit: - # XXX nkStrLit is VERY common in the traces, so we should avoid - # the 'copyNode' here. However, for now we cannot do this for unknown - # reasons. - result = n.copyNode + # nkStrLit is VERY common in the traces, so we should avoid + # the 'copyNode' here. + result = n #.copyNode of nkAsgn, nkFastAsgn: result = evalAsgn(c, n) of nkCommand..nkHiddenCallConv: result = evalMagicOrCall(c, n) |