On Sat, Jan 3, 2009 at 5:50 AM, Jason <jawo...@berkeley.edu> wrote: > > As you can see here, accessing elements of nested subvectors is slow. > > user> (doseq [i (map #(Math/pow 2 %) (range 0 16))] > (print i " ") > (let [sub (nth (iterate #(subvec % 0 1) [1]) i)] > (time (dotimes [_ 10000] (sub 0))))) > 1.0 "Elapsed time: 1.929 msecs" > ... > 128.0 "Elapsed time: 7.477 msecs" > ... > 32768.0 "Elapsed time: 10342.465 msecs" > > It seems the speed hit can be avoided by adding a special case to the > SubVector constructor in APersistentVector.java: > > public SubVector(IPersistentMap meta, IPersistentVector v, int start, > int end){ > super(meta); > if (v instanceof SubVector) { > SubVector s = (SubVector)v > this.v = s.v; > this.start = start + s.start; > this.end = end + s.start; > } else { > this.v = v; > this.start = start; > this.end = end; > } > } > > I've tested this a bit and it appears to work properly. Does this > seem like a good idea?
It seems like a good idea to me. Have you sent in your CA? See: http://clojure.org/contributing --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---