Skip to content
Browse files

* src/clj/cljs/core.clj: eliminate truth tests from satifies?

  • Loading branch information...
1 parent c227d59 commit 1be0a12c894703866433e2f410bf944535300420 David Nolen committed May 2, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/clj/cljs/core.clj
View
13 src/clj/cljs/core.clj
@@ -488,13 +488,14 @@
"Returns true if x satisfies the protocol"
[psym x]
(let [p (:name (cljs.compiler/resolve-var (dissoc &env :locals) psym))
- prefix (protocol-prefix p)]
- `(let [x# ~x]
- (if (and x#
- (. x# ~(symbol (core/str "-" prefix))) ;; Need prop lookup here
- (not (. x# (~'hasOwnProperty ~prefix))))
+ prefix (protocol-prefix p)
+ xsym (gensym)]
+ `(let [~xsym ~x]
+ (if (and (coercive-not= ~xsym nil)
+ ~(bool-expr `(. ~xsym ~(symbol (core/str "-" prefix)))) ;; Need prop lookup here
+ (coercive-not (. ~xsym (~'hasOwnProperty ~prefix))))
true
- (cljs.core/type_satisfies_ ~psym x#)))))
+ (cljs.core/type_satisfies_ ~psym ~xsym)))))
(defmacro lazy-seq [& body]
`(new cljs.core.LazySeq nil false (fn [] ~@body)))

0 comments on commit 1be0a12

Please sign in to comment.
Something went wrong with that request. Please try again.