Skip to content

Commit 96bdfbf

Browse files
committed
Fix inefficient pattern: if-exists -> exists-or-not-exists
1 parent e9d5515 commit 96bdfbf

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

ruby/ql/lib/codeql/ruby/printAst.qll

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,16 @@ class PrintRegularAstNode extends PrintAstNode, TPrintRegularAstNode {
121121
}
122122

123123
private int getSynthAstNodeIndex() {
124-
if
125-
exists(AstNode parent |
126-
shouldPrintAstEdge(parent, _, astNode) and
127-
synthChild(parent, _, astNode)
128-
)
129-
then
130-
exists(AstNode parent |
131-
shouldPrintAstEdge(parent, _, astNode) and
132-
synthChild(parent, result, astNode)
133-
)
134-
else result = 0
124+
exists(AstNode parent |
125+
shouldPrintAstEdge(parent, _, astNode) and
126+
synthChild(parent, result, astNode)
127+
)
128+
or
129+
not exists(AstNode parent |
130+
shouldPrintAstEdge(parent, _, astNode) and
131+
synthChild(parent, _, astNode)
132+
) and
133+
result = 0
135134
}
136135

137136
private int getSynthAstNodeIndexForSynthParent() {

0 commit comments

Comments
 (0)