cognitect / transit-cljs

Transit for ClojureScript
http://transit-format.org
Apache License 2.0
324 stars 21 forks source link

Comparing UUIDs is unnecessarily slow #32

Open rauhs opened 7 years ago

rauhs commented 7 years ago

With the current implementation:

(extend-protocol IComparable
  UUID
  (-compare [this other]
    (if (or (instance? UUID other)
            (instance? ty/UUID other))
      (compare (.toString this) (.toString other))
      (throw (js/Error. (str "Cannot compare " this " to " other)))))

The compare call will again check the strings for IComparable and even call (slow) native-satisfies this is very undesirable since I'm relying on fast comparisons in datascript datoms.

It'd be better if a call to garray/defaultCompare were made (as is done in cljs.core).