NRefactory icon indicating copy to clipboard operation
NRefactory copied to clipboard

RedundantAssignmentIssue is extremely slow when the control flow graph is complex

Open corngood opened this issue 10 years ago • 0 comments

This is probably easiest to explain by showing the test I wrote:

https://github.com/corngood/NRefactory/commit/c35584b934fb198a219321b2b54b4f492dd7bd9f

This test will take an extremely long time to complete, and scales non-linearly with the number of if statements. When walking a complex part of the call-graph which doesn't contain any references to the variable, it ends up doing an exhaustive search in RedundantAssignmentIssue.GatherVisitor.ProcessNode.

My initial thought was to just flag variables without any non-assignment references, but A slight variation on the test:

https://github.com/corngood/NRefactory/commit/bf5fe2aa2776e2d1f745c1e44b647d5c1d6509ca

shows the same behaviour can occur even when a reference exists.

corngood avatar Apr 10 '15 12:04 corngood