search: refactor doResults
Created by: stefanhengl
This is a refactoring of doResults
Why?
- This change should make some of the experiments we want to do around performance much easier. For example, for global searches, we plan to call zoekt much earlier, even before
determineRepos
. With this change, we can simply call a method on the new aggregator, instead of duplicating code in various places. - The new aggregator makes the purpose of the variables we previously declared much more explicit.
- doResults was (still is) very long.
What?
Previously
we declared a lot of variables in a block and kicked-off 1 goroutine per result type with each goroutine modifying the variables results
, common
, multiErr
, and fileMatches
(each protected by their own mutex).
Now
The variables are fields of a struct and each goroutine calls a method on this struct.
Downside
- we add yet another layer to our call hierarchy