Skip to content

Commit c53502a

Browse files
committed
C#: Improve performance of DeadStoreOfLocal.ql
1 parent 712b0d8 commit c53502a

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

csharp/ql/src/Dead Code/DeadStoreOfLocal.ql

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,12 @@ class RelevantDefinition extends AssignableDefinition {
141141
// Ensure that the definition is not in dead code
142142
exists(this.getAControlFlowNode()) and
143143
not this.isMaybeLive() and
144-
(
145-
// Allow dead initializer assignments, such as `string s = string.Empty`, but only
146-
// if the initializer expression assigns a default-like value, and there exists another
147-
// definition of the same variable
148-
this.isInitializer()
149-
implies
150-
(
151-
not this.isDefaultLikeInitializer()
152-
or
153-
not exists(AssignableDefinition other | other.getTarget() = this.getTarget() |
154-
other != this
155-
)
156-
)
157-
)
144+
// Allow dead initializer assignments, such as `string s = string.Empty`, but only
145+
// if the initializer expression assigns a default-like value, and there exists another
146+
// definition of the same variable
147+
if this.isDefaultLikeInitializer()
148+
then this = unique(AssignableDefinition def | def.getTarget() = this.getTarget())
149+
else any()
158150
}
159151
}
160152

0 commit comments

Comments
 (0)