UberProf performance improvements, beware of linq query evaluation
This is a diff from the performance improvement effort of UberProf. The simple addition of .ToList() has significantly improved the performance of this function:
Before adding the ToList(), each time we try to run our aggregation functions on the statements enumerable, we would force re-evaluation of the filtering (which can be quite expensive). By adding ToList() I am now making the filtering run only once.
There is another pretty obvious performance optimization that can be done here, can you see it? And why did I choose not to implement it?