This thread made me run a quick audit of our code and we had about a dozen calls to .length, a dozen calls to .substring, and a handful of calls to .replace - of which a few were in truly performance sensitive code (doing Unicode-related processing across large strings, so they had lots of other Java interop and type hints, and were deliberately procedural). Replacing the rest with count, subs, and clojure.string/replace (renamed to str-replace to avoid clojure.core/replace) definitely looks "nicer" and runs plenty faster enough for what we need.
So thanks to Alice for raising this and spurring me to make our code more idiomatic :) Sean On Fri, Nov 1, 2013 at 9:38 AM, <vrak...@gmail.com> wrote: > > > On Thursday, October 31, 2013 10:37:33 PM UTC-5, Mikera wrote: >> >> OTOH, count is much more generic since it can handle arbitrary sequences >> etc. Also count doesn't require type hints. You should definitely prefer >> count when writing most high level code. > > > Yes, I'd prefer count in higher level code over .length for easier Clojure / > ClojureScript code sharing. > > For what it's worth, src/clj/clojure/string.clj uses `.length` throughout > (except the capitalize function for I don't know why). > > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > 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 clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.