Sure, as I said if nobody is excited about the refactoring I will drop it, but let me respond with my reasoning for the changes:
Removes struct but adds lambda
The struct only seemed to have the purpose to transport the data between the two loops, this isn’t necessary with the new structure so it seemed to make more sense to remove it even though that didn’t save any LOCs. I find the lambda is simpler to reason about because it doesn’t carry any state.
Converts UniValue -> COutpoint -> UniValue, whereas master only does UniValue -> COutpoint
I would rather describe master as “UniValue → COutPoint + UniValue (wrapped in struct) → UniValue (unwrapped)” :)
It just seems more straight forward to me to handle the simpler std::vector<COutPoint>. The COutPoint already contains all the information needed to reconstruct the output object (txid + vout) so I just wouldn’t make a struct when it isn’t needed and I rely on existing, well-known types without too much hassle.
Adds 3 extra lines, complicating the mempool loop a lot, which simplifies the final loop, but not to much/any gain?
I still think that the new code is easier to reason about and if you want to quantify it I ran both RPC bodies through a word counter, the one I used says old code: 251, new code: 222, e.g. -10%. So while there are more lines, there is just less going on per line and the mental load to parse the code is still lower overall IMO.
But as I have said in the PR description already it isn’t a game changer, more of a style preference. I think there is a tangible benefit from this style that stuff like unnecessary checks/duplicate logic like this: #24539 (review) can be easier to spot and avoided. That’s why I prefer it :)
If nobody else shows up here over the weekend who is excited about the proposed changes then I will drop them (or even earlier if someone says they decidedly prefer that I drop them).