As I was trying to understand what IRExecutionUnit::FindInSymbols was doing, I couldn't help myself but refactor the code a little bit:
- No else after return.
- Move the lambda out of the loop.
- Replace GetSize() == 0 with IsEmpty()
- Eliminate pitfall of not clearing the SymbolContextList by moving it into the lexical scope of the if-clause.
And probably some other small things that bothered me.
It feels like the lambda should really be a small class that tracks the state of load_address and best_internal_load_address over multiple calls and then the user can access the state.
The lambda is doing a lot of logic and there is state being carried across calls and that feels like we have crossed the boundary and a class would be better.