On Wed, Jul 15, 2009 at 9:58 AM, Mark Engelberg<mark.engelb...@gmail.com> wrote:
> The problem with subvec is that it doesn't really create a "new"
> vector, it just adds a level of indirection off of the original
> vector.  So for example, if you look up, say, index 2 in the subvec,
> it knows to go look up index 5 in the original vec.  If you create a
> subvec of a subvec of a subvec, etc. pretty soon every lookup results
> in a chain of forty lookups until it gets to the original vector, and
> your performance grinds to a halt.

I take this back.  I realized that I was repeating an assertion I have
heard on this list, without confirming it for myself.  Looking at the
code for subvector, it looks like it indeed does the intelligent thing
and a subvec of a subvec points directly at the new start and end
bounds for the original vector.  So there really shouldn't be a
performance penalty for nested subvecs.  So your use of subvec in
stack-dropn is fine.

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