diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-05-28 13:42:32 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-05-28 13:42:32 +0000 |
commit | d702ebaf3bf40bd7367496a9f67dd5d0d81f68ae (patch) | |
tree | a4aa3b5c771ff78583236edd96a2610d3814c20a /src/clj | |
parent | ff27522840fb3c1681c331ad1fb44a313bd44e0a (diff) |
perf tweaks to count, nth
Diffstat (limited to 'src/clj')
-rw-r--r-- | src/clj/clojure/core.clj | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 6ff4a4c7..ab80af3d 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -849,6 +849,8 @@ (defn count "Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps" + {:tag Integer + :inline (fn [x] `(. clojure.lang.RT (count ~x)))} [coll] (. clojure.lang.RT (count coll))) ;;list stuff @@ -869,6 +871,8 @@ bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences." + {:inline (fn [c i] `(. clojure.lang.RT (nth ~c ~i))) + :inline-arities #{2}} ([coll index] (. clojure.lang.RT (nth coll index))) ([coll index not-found] (. clojure.lang.RT (nth coll index not-found)))) |