mirror of
https://github.com/servo/servo
synced 2026-05-14 02:47:14 +02:00
This change adds `NodeSet`, which is more or less a `Vec<Node>` that knows whether it is sorted, and can sort itself if it isn't. This allows us to efficiently enforce tree order in intermediary node sets that occur during evaluation. Notably, in many cases it is not necessary to sort at all, because all location step expressions yield node sets that are either already sorted (`Axis::DescendantOrSelf` for example), or that are in inverse tree order (`Axis::PrecedingSiblings` for example). There's still optimization work left to be done. When merging two node sets that are already sorted then we could use merge sort instead of appending one to the other and naively sorting. But I suspect that the sorting algorithm used by the standard library is already well tuned to handle such cases... Testing: This change adds a web platform test Fixes https://github.com/servo/servo/issues/40435 --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>