[webkit-dev] AncestorChainWalker substance and style thoughts

Ryosuke Niwa rniwa at webkit.org
Mon Feb 18 18:40:21 PST 2013

On Mon, Feb 18, 2013 at 6:38 PM, Darin Adler <darin at apple.com> wrote:

> On Feb 18, 2013, at 6:28 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
> > I had the same question when I found this class today but when I tried
> to turn it into a function, I realized that each caller of this function
> now needs to maintain two variables instead of one. Since those two
> variables (node and distributedNode) need to be in a consistent state, I've
> thought of creating a state object but then it seemed silly to create a
> state object only and a free function. It's much more natural for it be
> just a "walker" class.
> Does it? Is it really necessary to have the distributed node state or is
> that just performance optimization?

Many users of this class ends up walking up the ancestry tree. In that
case, having a state/iterator object like this makes sense.

But you're right in that the case of one off call to parent(), there isn't
much point in creating an object. We can probably get away with a single
function call.

- R. Niwa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130218/b1d40322/attachment.html>

More information about the webkit-dev mailing list