From ff4de2926c6f7dceca9bfa94bdeca66a2d362247 Mon Sep 17 00:00:00 2001 From: David Nolen Date: Wed, 5 Sep 2012 19:44:27 -0400 Subject: [PATCH] fail faster on js/Infinity && js/NaN since these cases much be tested anyway - doing arithmetic on these cases is slow. Extra tests do incur a small perf hit when testing actual numbers. --- src/cljs/cljs/core.cljs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cljs/cljs/core.cljs b/src/cljs/cljs/core.cljs index 20db4d986c..0656211327 100644 --- a/src/cljs/cljs/core.cljs +++ b/src/cljs/cljs/core.cljs @@ -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