So for a relatively small xrel with relatively few renames, there seems to be some performance gains to be had:
user> (def xrel {:a 1, :b 2, :c 3})
;; => #'user/xrel
user> (def kmap {:a :z})
;; => #'user/kmap
user> (quick-bench (set/rename-keys xrel kmap))
Evaluation count : 2959512 in 6 samples of 493252 calls.
Execution time mean : 200.870412 ns
Execution time std-deviation : 0.882651 ns
Execution time lower quantile : 200.116289 ns ( 2.5%)
Execution time upper quantile : 202.248092 ns (97.5%)
Overhead used : 2.151518 ns
Found 1 outliers in 6 samples (16.6667 %)
low-severe 1 (16.6667 %)
Variance from outliers : 13.8889 % Variance is moderately inflated by outliers
;; => nil
user> (quick-bench (set/rename-keys2 xrel kmap))
Evaluation count : 9627438 in 6 samples of 1604573 calls.
Execution time mean : 59.646747 ns
Execution time std-deviation : 0.083186 ns
Execution time lower quantile : 59.540415 ns ( 2.5%)
Execution time upper quantile : 59.723488 ns (97.5%)
Overhead used : 2.151518 ns
;; => nil
user>
For set/rename-keys2
defined as
(defn rename-keys2
"Returns the map with the keys in kmap renamed to the vals in kmap"
{:added "1.0"}
[map kmap]
(reduce-kv
(fn [m old new]
(if (contains? map old)
(-> m
(assoc new (get map old))
(dissoc old))
m)) map kmap))
Would something along these lines be interesting as a start for an investigation into improving rename-keys?