clojure-emacs / orchard

A fertile ground for Clojure tooling
Eclipse Public License 1.0
326 stars 54 forks source link

Optimize internal cache #187

Closed vemv closed 1 year ago

vemv commented 1 year ago

Fixes https://github.com/clojure-emacs/orchard/issues/186

Replaces the atom cache that would easily grow to huge values with a LruCache with capacity 250.

We also mostly stop populating the cache in advance. It's fairly pointless if we use a bounded capacity - no random classes are more important than others.

(We do populate the cache for a few key frequently-used classes, and whatever underlying classes they also need)

Cheers - V

bbatsov commented 1 year ago

Overall it looks OK to me. Generally I avoid introducing Java code when possible, but in this case it's fairly simple so not a big deal. Alternatively you could have done something like https://github.com/clojure/core.cache/blob/master/src/main/clojure/clojure/core/cache.clj#L211

vemv commented 1 year ago

Thanks for the review!