Skip to content

Commit 58cf95b

Browse files
committed
C#: Rewrite not using if.
1 parent 0cd4340 commit 58cf95b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

csharp/ql/src/semmle/code/csharp/controlflow/ControlFlowGraph.qll

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,16 +2059,15 @@ module ControlFlow {
20592059
result = first(cc.getExpr()) and
20602060
c instanceof SimpleCompletion
20612061
or
2062-
// Flow from last element of case expression to first element of statement
2063-
not exists(cc.getCondition()) and
20642062
cfe = lastConstCaseExpr(cc, c) and
2065-
c.(MatchingCompletion).isMatch() and
2066-
result = first(cc.getStmt())
2067-
or
2068-
// Flow from the last element of case expression to the condition
2069-
cfe = lastConstCaseExpr(cc, c) and
2070-
c.(MatchingCompletion).isMatch() and
2071-
result = first(cc.getCondition())
2063+
c.(MatchingCompletion).isMatch() and (
2064+
if exists(cc.getCondition()) then
2065+
// Flow from the last element of case expression to the condition
2066+
result = first(cc.getCondition())
2067+
else
2068+
// Flow from last element of case expression to first element of statement
2069+
result = first(cc.getStmt())
2070+
)
20722071
or
20732072
// Flow from last element of case condition to first element of statement
20742073
cfe = lastCaseCondition(cc, c) and

0 commit comments

Comments
 (0)