core.match generates a lot of code. In the future I might look into improving code size specifically for ClojureScript. That said, I can't say I really understand how this will matter much in the face of gzipping.
David On Sun, Jun 29, 2014 at 1:39 PM, Christoffer Sawicki <[email protected]> wrote: > Ahoy! > > The following funky code generates about 13 KB of JavaScript. A hand-written > version without core.match generates about 3 KB. It's about the same with > :optimizations set to :simple or :advanced. Is there anything I can do to > improve the core.match output? (I've tried both 0.2.1 and 0.2.2-SNAPSHOT.) > > The function basically just traverses a vector with look-ahead and looks for > patterns. If you have any suggestions on how to implement this completely > differently but better I'm all ears! > > (defn ^:private split [ss] > (let [cs (mapv classify-char ss)] > (loop [result [], start 0, i 0] > (let [result+new > (fn [end] > (if (> end start) > (conj result (.substring ^String ss start end)) > result)) > i+1 (+ i 1)] > (if (< i (count ss)) > (let [[m0 m1 m2] > (match [(subvec cs i)] > [[:whitespace & _]] > [(result+new i) i+1 i+1] > > [(:or [:lower :upper & _] > [:upper :upper :lower & _] > ;; (:not _) patterns would be nice below! > [:number (_ :guard #(not= % :number)) & _] > [(_ :guard #(not= % :number)) :number & _])] > [(result+new i+1) i+1 i+1] > > :else > [result start i+1])] > (recur m0 m1 m2)) ;; To avoid `recur` inside of `match` > (result+new i)))))) > > Also available for checkout here: > https://github.com/qerub/camel-snake-kebab/commits/wip-0.2.0 > > Just run `lein cljx once, cljsbuild once` and look at > target/cljsbuild-compiler-0/camel_snake_kebab/case_convert.js. > > Thanks, > Chris > > -- > Note that posts from new members are moderated - please be patient with your > first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/clojurescript. -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
