Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upConsider storing each DOM node's list of children as a vec in the node #25206
Comments
|
(Note that I suggest we do that in addition of the |
|
I think if it's good enough for Firefox, it's good enough for us. |
|
In that case will we still need the At a first glance it does seem to me that we can just switch over. It's not clear to me why we need NodeList to have both a Vec and a magical node-based form. |
|
Which fields are you talking about?
|
|
|
|
@nox yeah i guess i mean that we're using NodeList to store children but we use NodeList::Children instead of just a vec. We should just use a vec directly, and have NodeList::Children read from that vec.
Wasn't talking about nextSibling :) Some of these are O(1) |
Yeah, 2015 nox didn't want to allocate a vec when he could write some cute code instead. I optimised for the case where you just traverse |
|
We could still use that iterator for ChildNodes, actually, if it's a live iterator. |
|
If we always maintained that vector of children for each node, |
When I implemented
NodeListyears ago, I wrote a complicated caching system so that iterating from start to finish on the list of children wouldn't start again from the node's first child.On the other side of the pond, in Firefox, we just store a vec of nodes and access that in O(1). Furthermore, that vec is used in unrelated places too, even in layout.
If we did this in Servo, this could simplify parallel box construction a lot, and given Firefox does it, I'm not sure it's a huge performance hit.
Cc @jdm @SimonSapin