Maps:merge/1 idea

I’m curious how useful or sensible this might be: too often, I see code doing maps:merge(A, maps:merge(B, maps:merge(C, D))) (one example here: otp/lib/kernel/src/logger.erl at b2544ef4ce05c07fe793c570027caa51410dd66b · erlang/otp · GitHub), and I was wondering, what if we could do maps:merge([A, B, C, D]), how much more efficient that would be, if it could skip some allocations and computations of the intermediate results of the nested merges?

If somebody from the OTP team tells me this is a good idea, I can work on the implementation. Perhaps it’s an overkill and performance-wise it barely makes a difference, but dunno, asking for thoughts.

3 Likes