Permalink
Browse files

Avoid atomic overhead in Servo_Element_IsDisplayNone.

This reduces time spent in NoteDirtyElement by about 15% in the testcase. Even
though the subsequent patch will cause us to call Servo_Element_IsDisplayNone less
for this particular testcase, it could still be hot on other testcases, and so
it's worth optimizing.

MozReview-Commit-ID: 3F3Zfp48dDW
  • Loading branch information...
bholley committed Jan 11, 2018
1 parent ac74cf7 commit 2b1c1d7b6870902f13c1df136471176998731319
Showing with 7 additions and 2 deletions.
  1. +7 −2 ports/geckolib/glue.rs
View
@@ -1024,8 +1024,13 @@ pub extern "C" fn Servo_Element_GetPseudoComputedValues(element: RawGeckoElement
#[no_mangle]
pub extern "C" fn Servo_Element_IsDisplayNone(element: RawGeckoElementBorrowed) -> bool {
let element = GeckoElement(element);
let data = element.borrow_data().expect("Invoking Servo_Element_IsDisplayNone on unstyled element");
data.styles.is_display_none()
let data = element.get_data().expect("Invoking Servo_Element_IsDisplayNone on unstyled element");
// This function is hot, so we bypass the AtomicRefCell. It would be nice to also assert that
// we're not in the servo traversal, but this function is called at various intermediate
// checkpoints when managing the traversal on the Gecko side.
debug_assert!(is_main_thread());
unsafe { &*data.as_ptr() }.styles.is_display_none()
}
#[no_mangle]

0 comments on commit 2b1c1d7

Please sign in to comment.