Consolidate implementation of _process_totals
#523
+67
−105
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In particular, this unifies the duplicated implementations of these methods across
Filtered/ReportFile
.The new method also spells out a "very concise, but also unreadable" implementation that sums up the cyclomatic complexity (something I would like to remove completely eventually). This is now more readable and understandable, but more importantly, it only iterates over the
lines
once, instead of twice as the previous implementation did. Along with avoiding a bunch of intermediate list allocations that theFilteredReportFile
implementation did, this should yield quite a good speedup.I get the following benchmarks results now locally (as sadly, benchmarks are not yet fully working in CI):
Comparing this with the numbers in #512, we can see that the
process_totals
benchmark got a speedup of 2x (-50ms), and thefiltering
benchmark as well got sped up by -50ms.