Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove costly io/resource lookup that wasn't doing anything
The `immutable-source-file?` check is used in `class-info` to know if it makes sense to invalidate a cache entry based on modification time. This check uses the `:path` it is given to see if the resource is inside a jar or not. This `:path` comes from `orchard.java.{parser,legacy-parser}`, and is attained by calling `(.getPath (io/resource ...))`. This means it is either an absolute path on the filesystem, or it is a `file:..` URL pointing to a JAR. ```clojure (io/resource "lambdaisland/witchcraft.clj") ;;=> #java.net.URL "file:/srv/mc/witchcraft/src/lambdaisland/witchcraft.clj" (.getPath (io/resource "lambdaisland/witchcraft.clj")) ;;=> "/srv/mc/witchcraft/src/lambdaisland/witchcraft.clj" (io/resource "clojure/lang/RT.class") ;;=> #java.net.URL "jar:file:/root/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/lang/RT.class" (.getPath (io/resource "clojure/lang/RT.class")) ;;=> "file:/root/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/lang/RT.class" ``` Passing these things to `io/resource` again makes no sense, because these are absolute paths/urls, they can't be resolved relative to the classpath. This will always return nil. ```clojure (io/resource "file:/root/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/lang/RT.class") ;;=> nil ``` This check is performed whether the class-info is cached already or not, causing a full classpath scan on every call. The net effect is that depending on circumstances cider-nrepl's "classpath" op can get extremely slow, around 10~20 seconds to analyze all stack frames and return a result, which means that the error buffer will only pop up 10~20 seconds after evaluating a form which causes an error.
- Loading branch information