mirror of
https://github.com/servo/servo.git
synced 2025-06-20 15:18:58 +01:00
style: Inline GeckoNode::prev_sibling
It's very hot when matching some kind of selectors like the ones in bug 1717267, and the two function calls show up in the profiles. Differential Revision: https://phabricator.services.mozilla.com/D119505
This commit is contained in:
parent
695ff236c8
commit
1918c1c203
2 changed files with 6 additions and 4 deletions
|
@ -151,7 +151,7 @@ pub trait TNode: Sized + Copy + Clone + Debug + NodeInfo + PartialEq {
|
|||
/// Get this node's first child.
|
||||
fn first_child(&self) -> Option<Self>;
|
||||
|
||||
/// Get this node's first child.
|
||||
/// Get this node's last child.
|
||||
fn last_child(&self) -> Option<Self>;
|
||||
|
||||
/// Get this node's previous sibling.
|
||||
|
|
|
@ -409,9 +409,11 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
|||
#[inline]
|
||||
fn prev_sibling(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
bindings::Gecko_GetPreviousSibling(self.0)
|
||||
.as_ref()
|
||||
.map(GeckoNode)
|
||||
let prev_or_last = GeckoNode::from_content(self.0.mPreviousOrLastSibling.as_ref()?);
|
||||
if prev_or_last.0.mNextSibling.raw::<nsIContent>().is_null() {
|
||||
return None;
|
||||
}
|
||||
Some(prev_or_last)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue