Skip to content

Commit

Permalink
fail faster on js/Infinity && js/NaN since these cases much be tested…
Browse files Browse the repository at this point in the history
… anyway - doing arithmetic on these cases is slow. Extra tests do incur a small perf hit when testing actual numbers.
  • Loading branch information
David Nolen authored and David Nolen committed Sep 5, 2012
1 parent c7198c9 commit ff4de29
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cljs/cljs/core.cljs
Expand Up @@ -1019,8 +1019,9 @@ reduces them without incurring seq initialization"
"Returns true if n is an integer."
[n]
(and (number? n)
(coercive-= (js/parseFloat n) (js/parseInt n 10))
(not ^boolean (js/isNaN n))))
(not ^boolean (js/isNaN n))
(not (identical? n js/Infinity))
(== (js/parseFloat n) (js/parseInt n 10))))

(defn ^boolean contains?
"Returns true if key is present in the given collection, otherwise
Expand Down

0 comments on commit ff4de29

Please sign in to comment.