Hi,

On Thu, Oct 2, 2008 at 1:52 PM, Sridhar Raman <[EMAIL PROTECTED]> wrote:
> Here's another curious thing that I noticed.  In the first case, I was using
> node.getNodes() to get the iterator.  I tried node.getNodes("*"), and I
> notice that the skip method now is almost instantaneous.  Is this expected?

That's because getNodes("*") already traverses the list of all child
nodes before returning an iterator over the collection of all matching
nodes. The skip method is fast on the returned iterator just because
all the hard work has already been done.

The getNodes() method on the other hand tries to postpone the
expensive operations as long as possible, which is why it'll return
fast, but then the next() and skip() methods on the returned iterator
are more expensive.

BR,

Jukka Zitting

Reply via email to