Fixed #23745 -- Improved migrate speed

Of course, commit c7ea633 will not be eventually included, it only serves to measure performance.
I don't think we need an explicit `if` here. `_pending_lookups` is `{}` by default and thus the for-loop body isn't run anyways.