Small performance improvement in sempass2 (#7168)
This commit is contained in:
parent
90c1edff8b
commit
5460bd2764
1 changed files with 8 additions and 11 deletions
|
|
@ -593,17 +593,14 @@ proc trackOperand(tracked: PEffects, n: PNode, paramType: PType) =
|
||||||
notNilCheck(tracked, n, paramType)
|
notNilCheck(tracked, n, paramType)
|
||||||
|
|
||||||
proc breaksBlock(n: PNode): bool =
|
proc breaksBlock(n: PNode): bool =
|
||||||
case n.kind
|
# sematic check doesn't allow statements after raise, break, return or
|
||||||
of nkStmtList, nkStmtListExpr:
|
# call to noreturn proc, so it is safe to check just the last statements
|
||||||
for c in n:
|
var it = n
|
||||||
if breaksBlock(c): return true
|
while it.kind in {nkStmtList, nkStmtListExpr} and it.len > 0:
|
||||||
of nkBreakStmt, nkReturnStmt, nkRaiseStmt:
|
it = it.lastSon
|
||||||
return true
|
|
||||||
of nkCallKinds:
|
result = it.kind in {nkBreakStmt, nkReturnStmt, nkRaiseStmt} or
|
||||||
if n.sons[0].kind == nkSym and sfNoReturn in n.sons[0].sym.flags:
|
it.kind in nkCallKinds and it[0].kind == nkSym and sfNoReturn in it[0].sym.flags
|
||||||
return true
|
|
||||||
else:
|
|
||||||
discard
|
|
||||||
|
|
||||||
proc trackCase(tracked: PEffects, n: PNode) =
|
proc trackCase(tracked: PEffects, n: PNode) =
|
||||||
track(tracked, n.sons[0])
|
track(tracked, n.sons[0])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue