Closed
Description
Profiling reveals that kill_loans_out_of_scope_at_location
is a pretty major hot spot. It is pretty naive right now: for each point, it iterates over all borrows to check if that point is included. In fact, it seems to do that twice (@davidtwco opened #50891 to deal with that).
I am not sure the best way to handle this computation. One option that is not theoretically better but seems likely to be much better in practice would be:
- Iterate over each borrow expression B, with associated region
'a
:- For each borrow B, do a depth-first search starting at the location of the borrow
- When this DFS reaches a point P that is not in
'a
, end the walk, but addB
tokill
set for P
This is still O(n^2), but I think it seems likely to be much better in practice, and I can't think of a better way.