It would be nice if merge used transients.
Migrate c.c/merge later in core after transients & reduce. Leave older version as merge1 for use in cases the precede the newer definition. Make APersistentMap/conj & ATransientMap/cons aware of IKVReduce.
The attached patch preserves two existing behaviors of merge
the right hand side of the merges can be a Map.Entry, an IPersistentVector where size=2, and regular maps.
Can you update the ticket approach section to discuss the APersistentMap.cons / ASSOC changes. Also, can you add a before / after perf test for one or more common cases?
Updated patch to handle use of merge in core_print before it's defined in core
If anyone wants to take stewardship of this, go ahead. I had trouble getting consistent performance improvements on this. Obviously this needs fresh benchmarks.
Yes, this needs a benchmark showing demonstrable improvement. The whole goal here is improved perf - if we can't prove it's consistently faster, then there is no point in even reviewing it.
This ticket needs help. Step 0 is writing a benchmark harness that exercises maps of various sizes, and the various polymorphic arguments below.
After a benchmark harness, implementation code needs to preserve this behavior:
If the first argument is not nil, its metadata propagates to the result.
The arguments can be a Map.Entry, an IPersistentVector where size=2, and regular maps.
When passed a non-map as the first argument, result is undefined.