From 8a0ba0b3b09e7ab3f0f72f08c20b4c4ce5725e41 Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Thu, 2 Jun 2016 01:15:35 -0400 Subject: [PATCH] eliminate last cljs compiler warning --- CHANGES.md | 1 + src/clj/com/rpl/specter/impl.cljx | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8f9dd53..579d29f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ * More efficient inline caching for Clojure version, now inline caching is always within 5% of manually precompiled code * Significant performance improvement for ALL transform on maps for Clojure version (25% on simple benchmarks) * Significant performance improvements for FIRST/LAST for vectors +* Eliminated compiler warnings when used in ClojureScript ## 0.11.0 * New `path` macro does intelligent inline caching of the provided path. The path is factored into a static portion and into params which may change on each usage of the path (e.g. local parameters). The static part is factored and compiled on the first run-through, and then re-used for all subsequent invocations. As an example, `[ALL (keypath k)]` is factored into `[ALL keypath]`, which is compiled and cached, and `[k]`, which is provided on each execution. If it is not possible to precompile the path (e.g. [ALL some-local-variable]), nothing is cached and the path will be compiled on each run-through. diff --git a/src/clj/com/rpl/specter/impl.cljx b/src/clj/com/rpl/specter/impl.cljx index 1679afc..21864ae 100644 --- a/src/clj/com/rpl/specter/impl.cljx +++ b/src/clj/com/rpl/specter/impl.cljx @@ -43,16 +43,18 @@ (defn throw-illegal [& args] (throw (js/Error. (apply str args)))) -;; these macroexpand functions are for path macro in bootstrap cljs -;; environment +;; these macroexpand functions are for path macro in bootstrap cljs environment #+cljs (defn macroexpand' [form] - (binding [^:cljs.analyzer/no-resolve cljs.js/*eval-fn* - ^:cljs.analyzer/no-resolve cljs.js/js-eval] - (^:cljs.analyzer/no-resolve cljs.js/eval (^:cljs.analyzer/no-resolve cljs.js/empty-state) - `(macroexpand (quote ~form)) - identity))) + (let [orig-eval-fn ^:cljs.analyzer/no-resolve cljs.js/*eval-fn*] + (try + (set! ^:cljs.analyzer/no-resolve cljs.js/*eval-fn* ^:cljs.analyzer/no-resolve cljs.js/js-eval) + (^:cljs.analyzer/no-resolve cljs.js/eval (^:cljs.analyzer/no-resolve cljs.js/empty-state) + `(macroexpand (quote ~form)) + identity) + (finally + (set! ^:cljs.analyzer/no-resolve cljs.js/*eval-fn* orig-eval-fn))))) #+cljs (defn do-macroexpand-all