Skip to content

Commit

Permalink
* src/cljs/cljs/core.cljs: more cleanup. this does not work, we need …
Browse files Browse the repository at this point in the history
…to figure out how to pass "this" along as a real parameter.
  • Loading branch information
swannodette committed Jan 24, 2012
1 parent f692614 commit 72ac74a
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/cljs/cljs/core.cljs
Expand Up @@ -1993,18 +1993,18 @@ reduces them without incurring seq initialization"
(-reduce [v f]
(ci-reduce array f))
(-reduce [v f start]
(ci-reduce array f start)))
(ci-reduce array f start))

IFn
(-invoke [coll k]
(-lookup coll k))
(-invoke [coll k not-found]
(-lookup coll k not-found)))

(set! cljs.core.Vector/EMPTY (Vector. nil (array)))

(set! cljs.core.Vector/fromArray (fn [xs] (Vector. nil xs)))

(extend-type cljs.core.Vector
IFn
(-invoke
([_ k] (-lookup (js* "this") k))
([_ k not-found] (-lookup (js* "this") k not-found))))

(defn vec [coll]
(reduce conj cljs.core.Vector/EMPTY coll)) ; using [] here causes infinite recursion

Expand Down Expand Up @@ -2074,7 +2074,13 @@ reduces them without incurring seq initialization"
(-reduce [coll f]
(ci-reduce coll f))
(-reduce [coll f start]
(ci-reduce coll f start)))
(ci-reduce coll f start))

IFn
(-invoke [coll k]
(-lookup coll k))
(-invoke [coll k not-found]
(-lookup coll k not-found)))

(defn subvec
"Returns a persistent vector of the items in vector from
Expand All @@ -2087,12 +2093,6 @@ reduces them without incurring seq initialization"
([v start end]
(Subvec. nil v start end)))

(extend-type cljs.core.Subvec
IFn
(-invoke
([_ k] (-lookup (js* "this") k))
([_ k not-found] (-lookup (js* "this") k not-found))))

;;; PersistentQueue ;;;

(deftype PersistentQueueSeq [meta front rear]
Expand Down Expand Up @@ -2279,18 +2279,18 @@ reduces them without incurring seq initialization"
(.splice new-keys (scan-array 1 k new-keys) 1)
(js-delete new-strobj k)
(ObjMap. meta new-keys new-strobj))
coll))) ; key not found, return coll unchanged
coll)) ; key not found, return coll unchanged

IFn
(-invoke [coll k]
(-lookup coll k))
(-invoke [coll k not-found]
(-lookup coll k not-found)))

(set! cljs.core.ObjMap/EMPTY (ObjMap. nil (array) (js-obj)))

(set! cljs.core.ObjMap/fromObject (fn [ks obj] (ObjMap. nil ks obj)))

(extend-type cljs.core.ObjMap
IFn
(-invoke
([_ k] (-lookup (js* "this") k))
([_ k not-found] (-lookup (js* "this") k not-found))))

; The keys field is an array of all keys of this map, in no particular
; order. Each key is hashed and the result used as a property name of
; hashobj. Each values in hashobj is actually a bucket in order to handle hash
Expand Down Expand Up @@ -2377,7 +2377,13 @@ reduces them without incurring seq initialization"
(let [new-bucket (aclone bucket)]
(.splice new-bucket i 2)
(aset new-hashobj h new-bucket)))
(HashMap. meta (dec count) new-hashobj))))))
(HashMap. meta (dec count) new-hashobj)))))

IFn
(-invoke [coll k]
(-lookup coll k))
(-invoke [coll k not-found]
(-lookup coll k not-found)))

(set! cljs.core.HashMap/EMPTY (HashMap. nil 0 (js-obj)))

Expand All @@ -2388,12 +2394,6 @@ reduces them without incurring seq initialization"
(recur (inc i) (assoc out (aget ks i) (aget vs i)))
out)))))

(extend-type cljs.core.HashMap
IFn
(-invoke
([_ k] (-lookup (js* "this") k))
([_ k not-found] (-lookup (js* "this") k not-found))))

(defn hash-map
"keyval => key val
Returns a new hash map with supplied mappings."
Expand Down Expand Up @@ -2494,15 +2494,15 @@ reduces them without incurring seq initialization"

ISet
(-disjoin [coll v]
(Set. meta (dissoc hash-map v))))

(set! cljs.core.Set/EMPTY (Set. nil (hash-map)))
(Set. meta (dissoc hash-map v)))

(extend-type cljs.core.Set
IFn
(-invoke
([_ k] (-lookup (js* "this") k))
([_ k not-found] (-lookup (js* "this") k not-found))))
(-invoke [coll k]
(-lookup coll k))
(-invoke [coll k not-found]
(-lookup coll k not-found)))

(set! cljs.core.Set/EMPTY (Set. nil (hash-map)))

(defn set
"Returns a set of the distinct elements of coll."
Expand Down

0 comments on commit 72ac74a

Please sign in to comment.