Permalink
Browse files

TNS-4: Eliminate several uses of reflection in tools.namespace

Signed-off-by: Stuart Sierra <mail@stuartsierra.com>
  • Loading branch information...
1 parent 1a46376 commit ada4479c4a22daf0410ca51fac0c09a26ab8e9ae @jafingerhut jafingerhut committed with stuartsierra Oct 29, 2012
@@ -109,7 +109,7 @@
loader-classpath
(take-while
identity
- (iterate #(.getParent %) classloader)))))
+ (iterate #(.getParent ^ClassLoader %) classloader)))))
([] (classpath (clojure.lang.RT/baseLoader))))
(defn- classpath-directories []
@@ -71,10 +71,10 @@
DependencyGraphUpdate
(depend [graph node dep]
(when (depends? graph dep node)
- (throw (Exception.
- (binding [*print-length* 10]
- (str "Circular dependency between "
- (pr-str node) " and " (pr-str dep))))))
+ (let [^String msg (binding [*print-length* 10]
+ (str "Circular dependency between "
+ (pr-str node) " and " (pr-str dep)))]
+ (throw (Exception. msg))))
(MapDependencyGraph.
(update-in dependencies [node] set-conj dep)
(update-in dependents [dep] set-conj node)))
@@ -20,13 +20,13 @@
(defn- find-files [dirs]
(->> dirs
(map io/file)
- (filter #(.exists %))
+ (filter #(.exists ^File %))
(mapcat file-seq)
(filter file/clojure-file?)
- (map #(.getCanonicalFile %))))
+ (map #(.getCanonicalFile ^File %))))
(defn- modified-files [tracker files]
- (filter #(< (::time tracker 0) (.lastModified %)) files))
+ (filter #(< (::time tracker 0) (.lastModified ^File %)) files))
(defn- deleted-files [tracker files]
(set/difference (::files tracker #{}) (set files)))
@@ -41,8 +41,8 @@
(assoc ::time now))))
(defn- dirs-on-classpath []
- (filter #(.isDirectory %)
- (map #(File. %)
+ (filter #(.isDirectory ^File %)
+ (map #(File. ^String %)
(string/split
(System/getProperty "java.class.path")
(Pattern/compile (Pattern/quote File/pathSeparator))))))
@@ -70,4 +70,4 @@
(let [ds (or (seq dirs) (dirs-on-classpath))
files (find-files ds)
deleted (seq (deleted-files tracker files))]
- (update-files tracker deleted files)))
+ (update-files tracker deleted files)))
@@ -25,7 +25,7 @@
(defn clojure-file?
"Returns true if the java.io.File represents a normal Clojure source
file."
- [file]
+ [^java.io.File file]
(and (.isFile file)
(.endsWith (.getName file) ".clj")))

0 comments on commit ada4479

Please sign in to comment.