Do Clojure still have rooms to improve at compiler level?

Someone at work pointed this out recently

(let [f-keys (fn [{:keys [foo bar] :as m}]
               (str foo bar))
      f-kws (fn [{foo :foo bar :bar :as m}]
              (str foo bar))
      f-gets (fn [m]
               (str (:foo m) (:bar m)))
      m {:foo "a" :bar "b"}]
  (c/quick-bench (f-keys m))   ; // 111.027050 ns
  (c/quick-bench (f-kws m))    ; // 106.243598 ns
  (c/quick-bench (f-gets m)))  ; //  71.026220 ns

When I run this locally I get less dramatic differences but still significant (~15% vs the posted ~56% slowdown). If these numbers are at all accurate that suggests there could be a lot to be gained by doing some simple optimizations in the compiler

1 Like