switch can be compiled to a direct array indexing operation or a binary search. I believe that's what the JVM does for tableswitch and lookupswitch, respectively.
On 19 February 2014 01:02, t x <[email protected]> wrote: > With apologies for potential stupidity: > > * (get {... } key) is an operation that is O(log n) worst case (if > using Red-Black trees) or O(1) average case (hashing) > > * (get { ... } key) does not have integer/string limitation > > Therefore: why are we not "compiling down to get" ? Are the big-Oh > constants enormous? > > On Tue, Feb 18, 2014 at 3:51 PM, Michał Marczyk > <[email protected]> wrote: >> Great! First cut at compiling case to switch (when given numbers and >> strings only as tests at the moment, but this can be improved) here: >> >> https://github.com/michalmarczyk/clojurescript/tree/713-compile-case-to-switch >> >> I'll post more details on the ticket. >> >> Cheers, >> Michał >> >> >> On 18 February 2014 22:38, David Nolen <[email protected]> wrote: >>> Due to asm.js some JS engines are starting to compile switch statements >>> where the cases are integers into jump tables. Compiler enhancement that >>> compiles optimizable case expressions to JS switch statements would be a >>> welcome enhancement - http://dev.clojure.org/jira/browse/CLJS-713. >>> >>> David >>> >>> >>> On Tue, Feb 18, 2014 at 4:35 PM, t x <[email protected]> wrote: >>>> >>>> Looking at >>>> https://github.com/clojure/clojurescript/blob/r2156/src/clj/cljs/core.clj#L1144-L1147 >>>> , you win. :-) >>>> >>>> On Tue, Feb 18, 2014 at 1:33 PM, Michał Marczyk >>>> <[email protected]> wrote: >>>> > On 18 February 2014 22:31, Michał Marczyk <[email protected]> >>>> > wrote: >>>> >> Actually in ClojureScript case dispatch is O(n), since it's >>>> >> implemented as a macro expanding to cond. >>>> > >>>> > As of release 2156: >>>> > >>>> > >>>> > https://github.com/clojure/clojurescript/blob/r2156/src/clj/cljs/core.clj#L1119 >>>> > >>>> > -- >>>> > You received this message because you are subscribed to the Google >>>> > Groups "Clojure" group. >>>> > To post to this group, send email to [email protected] >>>> > Note that posts from new members are moderated - please be patient with >>>> > your first post. >>>> > To unsubscribe from this group, send email to >>>> > [email protected] >>>> > For more options, visit this group at >>>> > http://groups.google.com/group/clojure?hl=en >>>> > --- >>>> > You received this message because you are subscribed to the Google >>>> > Groups "Clojure" group. >>>> > To unsubscribe from this group and stop receiving emails from it, send >>>> > an email to [email protected]. >>>> > For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Clojure" group. >>>> To post to this group, send email to [email protected] >>>> Note that posts from new members are moderated - please be patient with >>>> your first post. >>>> To unsubscribe from this group, send email to >>>> [email protected] >>>> For more options, visit this group at >>>> http://groups.google.com/group/clojure?hl=en >>>> --- >>>> You received this message because you are subscribed to the Google Groups >>>> "Clojure" group. >>>> To unsubscribe from this group and stop receiving emails from it, send an >>>> email to [email protected]. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> To post to this group, send email to [email protected] >>> Note that posts from new members are moderated - please be patient with your >>> first post. >>> To unsubscribe from this group, send email to >>> [email protected] >>> For more options, visit this group at >>> http://groups.google.com/group/clojure?hl=en >>> --- >>> You received this message because you are subscribed to the Google Groups >>> "Clojure" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to [email protected]. >>> For more options, visit https://groups.google.com/groups/opt_out. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to [email protected] >> Note that posts from new members are moderated - please be patient with your >> first post. >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
