mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Make GetFlattenedTreeParent more straight-forward.
Now that accessing nsIContent slots is not a blob of virtual function calls, we should be able to unify logic here, and speed up the not-so-rare case for chrome, while keeping the usual case fast. Bug: 1427511 Reviewed-by: smaug MozReview-Commit-ID: 87iY5Cbhx4T
This commit is contained in:
parent
27a443fbaa
commit
51e2942c25
2 changed files with 17 additions and 9 deletions
|
@ -503,8 +503,6 @@ extern "C" {
|
||||||
pub fn Gecko_RecordTraversalStatistics ( total : u32 , parallel : u32 , total_t : u32 , parallel_t : u32 , total_s : u32 , parallel_s : u32 , ) ;
|
pub fn Gecko_RecordTraversalStatistics ( total : u32 , parallel : u32 , total_t : u32 , parallel_t : u32 , total_s : u32 , parallel_s : u32 , ) ;
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
pub fn Gecko_IsInDocument ( node : RawGeckoNodeBorrowed , ) -> bool ;
|
pub fn Gecko_IsInDocument ( node : RawGeckoNodeBorrowed , ) -> bool ;
|
||||||
} extern "C" {
|
|
||||||
pub fn Gecko_FlattenedTreeParentIsParent ( node : RawGeckoNodeBorrowed , ) -> bool ;
|
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
pub fn Gecko_IsSignificantChild ( node : RawGeckoNodeBorrowed , text_is_significant : bool , whitespace_is_significant : bool , ) -> bool ;
|
pub fn Gecko_IsSignificantChild ( node : RawGeckoNodeBorrowed , text_is_significant : bool , whitespace_is_significant : bool , ) -> bool ;
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
|
|
|
@ -236,13 +236,23 @@ impl<'ln> GeckoNode<'ln> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn flattened_tree_parent(&self) -> Option<Self> {
|
fn flattened_tree_parent(&self) -> Option<Self> {
|
||||||
let fast_path = self.flattened_tree_parent_is_parent();
|
// TODO(emilio): Measure and consider not doing this fast-path and take
|
||||||
debug_assert!(fast_path == unsafe { bindings::Gecko_FlattenedTreeParentIsParent(self.0) });
|
// always the common path, it's only a function call and from profiles
|
||||||
if fast_path {
|
// it seems that keeping this fast path makes the compiler not inline
|
||||||
unsafe { self.0.mParent.as_ref().map(GeckoNode) }
|
// `flattened_tree_parent`.
|
||||||
} else {
|
if self.flattened_tree_parent_is_parent() {
|
||||||
unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).map(GeckoNode) }
|
debug_assert_eq!(
|
||||||
|
unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).map(GeckoNode) },
|
||||||
|
self.parent_node(),
|
||||||
|
"Fast path stopped holding!"
|
||||||
|
);
|
||||||
|
|
||||||
|
return self.parent_node();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(emilio): If this call is too expensive, we could manually
|
||||||
|
// inline more aggressively.
|
||||||
|
unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).map(GeckoNode) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue