Auto merge of #19453 - emilio:is-root-is-slow, r=upsuper

style: Add a fast-path for GeckoElement::is_root.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19453)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-12-01 15:14:13 -06:00 committed by GitHub
commit bca8951182

View file

@ -1917,6 +1917,15 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
#[inline] #[inline]
fn is_root(&self) -> bool { fn is_root(&self) -> bool {
let parent_node = match self.as_node().parent_node() {
Some(parent_node) => parent_node,
None => return false,
};
if !parent_node.is_document() {
return false;
}
unsafe { unsafe {
Gecko_IsRootElement(self.0) Gecko_IsRootElement(self.0)
} }