On Oct 18, 4:44 pm, "nicolas.o...@gmail.com" <nicolas.o...@gmail.com>
wrote:
> I happened to stumble on something like that in 1.2, with
> = slower than >=, which is in turn slower than zero?.
> (Even when everything is a primitive)
>
> I never really understood why and would be happy to understand it better.
> Dimitry, have you tryed to replace (= x y) by (zero? (- x u)), or with
> an unchecked substraction?

16 msec (>= ~idx  (alength a#)) -- speed of the original areduce
17 msec (zero? (unchecked-subtract (alength a#) ~idx))
33 msec (zero? (- (alength a#) ~idx))
293 msec (= ~idx  (alength a#))

(defmacro areduce-2
  [a idx ret init expr]
  `(let [a# ~a]
     (loop  [~idx (int 0) ~ret ~init]
       (if (>= ~idx (alength a#))
         ~ret
         (recur (unchecked-inc ~idx) ~expr)))))

So, the problem is really about '=' operator.
I wonder, could it be some kind of special op
(like eq / eqn / equal in Common Lisp)?

Regards,
  Dmitriy

-- 
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

Reply via email to