Clojure performance - why does the "ugly" "array swap trick" improve lcs performance? -


this follow @cgrand's answer question "clojure performance expensive algorithms." haven been studying , trying apply of techniques own experimental clojure perf tuning.

one thing wondering "ugly" "arrays swap trick"

      (set! curr prev)       (set! prev bak) 

how , why improve performance on original approach? suspect clojure arrays not true java primitive arrays? if necessary, please cite clojure core source in answer.

as chas mentions, loops primitive hints problematic. clojure attempts keep ints unboxed when provide hint, (for part) silently fail when can't honor hints. therefore forcing happen creating deftype mutable fields , setting inside loop. it's ugly hack, gets around few limitations in compiler.


Comments