Skip to content

Commit 646af3e

Browse files
vemvbbatsov
authored andcommitted
Don't compute io/resource twice for :path
1 parent 3e448d5 commit 646af3e

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

src-jdk8/orchard/java/legacy_parser.clj

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,14 @@
270270
(try
271271
(let [path (source-path klass)]
272272
(when-let [root (parse-java path)]
273-
(assoc (->> (map parse-info (.classes root))
274-
(filter #(= klass (:class %)))
275-
(first))
276-
;; relative path on the classpath
277-
:file path
278-
;; Legacy key. Please do not remove - we don't do breaking changes!
279-
:path (-> path io/resource .getPath)
280-
;; Full URL, e.g. file:.. or jar:...
281-
:resource-url (io/resource path))))
273+
(let [path-resource (io/resource path)]
274+
(assoc (->> (map parse-info (.classes root))
275+
(filter #(= klass (:class %)))
276+
(first))
277+
;; relative path on the classpath
278+
:file path
279+
;; Legacy key. Please do not remove - we don't do breaking changes!
280+
:path (.getPath path-resource)
281+
;; Full URL, e.g. file:.. or jar:...
282+
:resource-url path-resource))))
282283
(catch Abort _)))

src-newer-jdks/orchard/java/parser.clj

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -296,19 +296,20 @@
296296
(when-let [path (source-path klass)]
297297
(when-let [^DocletEnvironment root (parse-java path (module-name klass))]
298298
(try
299-
(assoc (->> (.getIncludedElements root)
300-
(filter #(#{ElementKind/CLASS
301-
ElementKind/INTERFACE
302-
ElementKind/ENUM}
303-
(.getKind ^Element %)))
304-
(map #(parse-info % root))
305-
(filter #(= klass (:class %)))
306-
(first))
307-
;; relative path on the classpath
308-
:file path
309-
;; Legacy key. Please do not remove - we don't do breaking changes!
310-
:path (-> path io/resource .getPath)
311-
;; Full URL, e.g. file:.. or jar:...
312-
:resource-url (io/resource path))
299+
(let [path-resource (io/resource path)]
300+
(assoc (->> (.getIncludedElements root)
301+
(filter #(#{ElementKind/CLASS
302+
ElementKind/INTERFACE
303+
ElementKind/ENUM}
304+
(.getKind ^Element %)))
305+
(map #(parse-info % root))
306+
(filter #(= klass (:class %)))
307+
(first))
308+
;; relative path on the classpath
309+
:file path
310+
;; Legacy key. Please do not remove - we don't do breaking changes!
311+
:path (.getPath path-resource)
312+
;; Full URL, e.g. file:.. or jar:...
313+
:resource-url path-resource))
313314
(finally (.close (.getJavaFileManager root))))))
314315
(catch Throwable _)))

0 commit comments

Comments
 (0)