Quote from AdirelleWith my piece of code I also realized that the GUID->unit map may return something like raidN or raidpetN but oUF unit->frame map contains data only for partyN or partypetN (or conversely, I don't clearly remember). So basically I think unit->frame maps just won't work: you have to scan all frames and check if UnitIsUnit(unit, frame.unit). This also solves possible issue when the same unit is displayed more than one. (I'm realizing I could just drop my GUID->frame map and find another solution)
I found this as well when creating oUF_HealComm4. As it is an optional extra on top of any oUF layout(s) then I had to scan every frame to make sure all the appropriate frames get updated. My own oUF layouts can have the player shown simultaneously in 4 places typically (player, targetoftarget, raid and MainTank frames).
I still need to optimise the code some more, but for the moment it has acceptable performance. Feel free to borrow any ideas from what I've done so far, and if you have any suggestions for improvements then send me a PM.