Skip to content

Commit

Permalink
fixes nim-lang/RFCs#257 [backport:1.2] (#15479)
Browse files Browse the repository at this point in the history
(cherry picked from commit 2288188)
  • Loading branch information
Araq authored and narimiran committed Oct 6, 2020
1 parent e3c85f5 commit 9599d95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 0 additions & 7 deletions compiler/transf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -830,13 +830,6 @@ proc transformExceptBranch(c: PTransf, n: PNode): PNode =
else:
result = transformSons(c, n)

proc dontInlineConstant(orig, cnst: PNode): bool {.inline.} =
# symbols that expand to a complex constant (array, etc.) should not be
# inlined, unless it's the empty array:
result = orig.kind == nkSym and
cnst.kind in {nkCurly, nkPar, nkTupleConstr, nkBracket} and
cnst.len != 0

proc commonOptimizations*(g: ModuleGraph; c: PSym, n: PNode): PNode =
result = n
for i in 0..<n.safeLen:
Expand Down
7 changes: 7 additions & 0 deletions compiler/trees.nim
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,10 @@ proc flattenStmts*(n: PNode): PNode =
proc extractRange*(k: TNodeKind, n: PNode, a, b: int): PNode =
result = newNodeI(k, n.info, b-a+1)
for i in 0..b-a: result[i] = n[i+a]

proc dontInlineConstant*(orig, cnst: PNode): bool {.inline.} =
# symbols that expand to a complex constant (array, etc.) should not be
# inlined, unless it's the empty array:
result = orig.kind == nkSym and
cnst.kind in {nkCurly, nkPar, nkTupleConstr, nkBracket, nkObjConstr} and
cnst.len > ord(cnst.kind == nkObjConstr)

0 comments on commit 9599d95

Please sign in to comment.