On Sun, Nov 14, 2010 at 3:36 PM, Eric Kobrin <erl...@gmail.com> wrote:
> In the particular bit of code I'm working on, I have a collection of > vectors. The last one is always [] and no others are empty. Using > `identical?` instead of `seq` to detect that last vector shaved quite > a bit of time in my loop. The use of identical? is just wrong. It checks whether two objects are in fact the same object in memory. The fact that: (identical? [] []) ; true is just an implementation detail. The compiler *happened* to use the same object - it's an optimization for constant literals. Better to use a real sentinel. Also such low timings for 1e8 iterations should being a warning sign that perhaps you are not measuring what you think you are measuring. Your (identical? [] []) is likely becoming a no-op. In the general case, if you're using vectors and loop anyway for performance reasons, (= (count v) 0) to check for a empty vector is plenty fast and resource efficient. David -- 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