Commits

Meikel Brandmeyer committed 67a7fb7

Made code 100% reflection free

Comments (0)

Files changed (3)

src/de/kotka/lazymap/LazyMap.clj

   [[] theMap])
 
 (defn- -lazyAssoc
-  [this k v]
-  (new de.kotka.lazymap.LazyMap (-> this .theMap (.assoc k v))))
+  [#^de.kotka.lazymap.LazyMap this k v]
+  (de.kotka.lazymap.LazyMap. (-> this .theMap (assoc k v))))
 
 ; IObj
 (defn- -meta
-  [this]
-  (-> this .theMap .meta))
+  [#^de.kotka.lazymap.LazyMap this]
+  (-> this .theMap meta))
 
 (defn- -withMeta
-  [this meta-data]
-  (new de.kotka.lazymap.LazyMap (-> this .theMap (.withMeta meta-data))))
+  [#^de.kotka.lazymap.LazyMap this meta-data]
+  (de.kotka.lazymap.LazyMap. (-> this .theMap (with-meta meta-data))))
 
 ; IPersistentMap
 (defn- -assoc
-  [this k v]
-  (new de.kotka.lazymap.LazyMap (-> this .theMap (.assoc k (delay v)))))
+  [#^de.kotka.lazymap.LazyMap this k v]
+  (de.kotka.lazymap.LazyMap. (-> this .theMap (assoc k (delay v)))))
 
 (defn- -assocEx
-  [this k v]
-  (when (. this containsKey k)
-    (throw (new Exception (str "Key alread present: " k))))
-  (. this assoc k v))
+  [#^de.kotka.lazymap.LazyMap this k v]
+  (when (.containsKey this k)
+    (throw (Exception. (str "Key alread present: " k))))
+  (.assoc this k v))
 
 (defn- -without
-  [this k]
-  (new de.kotka.lazymap.LazyMap (-> this .theMap (.without k))))
+  [#^de.kotka.lazymap.LazyMap this k]
+  (-> this .theMap (dissoc k) de.kotka.lazymap.LazyMap.))
 
 ; Associative
 (defn- -containsKey
-  [this k]
-  (-> this .theMap (.containsKey k)))
+  [#^de.kotka.lazymap.LazyMap this k]
+  (-> this .theMap (contains? k)))
 
 (defn- -entryAt
-  [this k]
-  (new de.kotka.lazymap.LazyMapEntry k (-> this .theMap (.valAt k))))
+  [#^de.kotka.lazymap.LazyMap this k]
+  (de.kotka.lazymap.LazyMapEntry. k (-> this .theMap (get k))))
 
 (defn- -valAt
-  ([this k]
-   (. this valAt k nil))
-  ([this k nf]
-   (if (-> this .theMap (.containsKey k))
-     (force (-> this .theMap (.valAt k)))
+  ([#^de.kotka.lazymap.LazyMap this k]
+   (.valAt this k nil))
+  ([#^de.kotka.lazymap.LazyMap this k nf]
+   (if (-> this .theMap (contains? k))
+     (-> this .theMap (get k) force)
      nf)))
 
 ; Iterable
 (defn- -iterator
-  [this]
-  (new SeqIterator (. this seq)))
+  [#^de.kotka.lazymap.LazyMap this]
+  (-> this .seq SeqIterator.))
 
 ; IPersistentCollection
 (defn- -count
-  [this]
-  (-> this .theMap .count))
+  [#^de.kotka.lazymap.LazyMap this]
+  (-> this .theMap count))
 
 (defn- -seq
-  [this]
-  (when-let [inner-seq (-> this .theMap .seq)]
-    (new de.kotka.lazymap.LazyMapSeq inner-seq)))
+  [#^de.kotka.lazymap.LazyMap this]
+  (when-let [inner-seq (-> this .theMap seq)]
+    (de.kotka.lazymap.LazyMapSeq. inner-seq)))
 
 (defn- -cons
-  [this o]
+  [#^de.kotka.lazymap.LazyMap this o]
   (condp instance? o
     de.kotka.lazymap.LazyMapEntry
-                      (let [k (. o getKey)
-                            v (. o getRawValue)]
-                        (. this lazyAssoc k v))
-    IMapEntry         (let [k (. o getKey)
-                            v (. o getValue)]
-                        (. this assoc k (delay v)))
+                      (let [#^de.kotka.lazymap.LazyMapEntry o o]
+                        (let [k (.getKey o)
+                              v (.getRawValue o)]
+                          (.lazyAssoc this k v)))
+    IMapEntry         (let [#^IMapEntry o o]
+                        (let [k (.getKey o)
+                              v (.getValue o)]
+                          (.assoc this k (delay v))))
     IPersistentVector (if (= (count o) 2)
                         (let [k (o 0)
                               v (o 1)]
-                          (. this assoc k (delay v)))
-                        (throw (new IllegalArgumentException
+                          (.assoc this k (delay v)))
+                        (throw (IllegalArgumentException.
                                     "Vector arg to map conj must be a pair")))
-    (reduce #(. %1 cons %2) this o)))
+    (reduce #(.cons #^de.kotka.lazymap.LazyMap %1 %2) this o)))
 
 (defn- -empty
-  [this]
-  (new de.kotka.lazymap.LazyMap (-> this .theMap .empty)))
+  [#^de.kotka.lazymap.LazyMap this]
+  (-> this .theMap empty de.kotka.lazymap.LazyMap.))
 
 ; IFn
 (defn- -invoke
-  [this & ks]
-  (. this valAt (first ks)))
+  [#^de.kotka.lazymap.LazyMap this & ks]
+  (.valAt this (first ks)))
 
 (defn- -applyTo
-  [this ks]
-  (. this valAt (first ks)))
+  [#^de.kotka.lazymap.LazyMap this ks]
+  (.valAt this (first ks)))

src/de/kotka/lazymap/LazyMapEntry.clj

   [[] (struct entry-state k v)])
 
 (defn- -getKey
-  [this]
-  ((. this theState) :theKey))
+  [#^de.kotka.lazymap.LazyMapEntry this]
+  (-> this .theState :theKey))
 
 (defn- -key
-  [this]
+  [#^de.kotka.lazymap.LazyMapEntry this]
   (.getKey this))
 
 (defn- -getValue
-  [this]
-  (force (.getRawValue this)))
+  [#^de.kotka.lazymap.LazyMapEntry this]
+  (-> this .getRawValue force))
 
 (defn- -val
-  [this]
+  [#^de.kotka.lazymap.LazyMapEntry this]
   (.getValue this))
 
 (defn- -getRawValue
-  [this]
-  ((.theState this) :theValue))
+  [#^de.kotka.lazymap.LazyMapEntry this]
+  (-> this .theState :theValue))
 
 (defn- -toString
-  [this]
+  [#^de.kotka.lazymap.LazyMapEntry this]
   (str \[ (.key this) \space (.val this) \]))
 
 (defmethod print-method de.kotka.lazymap.LazyMapEntry
-  [this #^java.io.Writer w]
+  [#^de.kotka.lazymap.LazyMapEntry this #^java.io.Writer w]
   (.write w (.toString this)))

src/de/kotka/lazymap/LazyMapSeq.clj

 
 ; ISeq
 (defn- -first
-  [this]
+  [#^de.kotka.lazymap.LazyMapSeq this]
   (let [first-val (first (.theSeq this))]
-    (new de.kotka.lazymap.LazyMapEntry (key first-val) (val first-val))))
+    (de.kotka.lazymap.LazyMapEntry. (key first-val) (val first-val))))
 
 (defn- -more
-  [this]
+  [#^de.kotka.lazymap.LazyMapSeq this]
   (if-let [inner-rest (next (.theSeq this))]
-    (new de.kotka.lazymap.LazyMapSeq inner-rest)
+    (de.kotka.lazymap.LazyMapSeq. inner-rest)
     clojure.lang.PersistentList/EMPTY))
 
 (defn- -next
-  [this]
+  [#^de.kotka.lazymap.LazyMapSeq this]
   (when-let [inner-rest (next (.theSeq this))]
-    (new de.kotka.lazymap.LazyMapSeq inner-rest)))
+    (de.kotka.lazymap.LazyMapSeq. inner-rest)))
 
 (defn- -cons
-  [this other]
-  (new Cons other this))
+  [#^de.kotka.lazymap.LazyMapSeq this other]
+  (Cons. other this))
 
 ; IPersistentCollection
 (defn- -count
-  [this]
+  [#^de.kotka.lazymap.LazyMapSeq this]
   (-> this .theSeq count))
 
 (def #^{:private true} -seq identity)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.