Skip to content

Commit

Permalink
Avoid atomic overhead in Servo_Element_IsDisplayNone.
Browse files Browse the repository at this point in the history
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 12, 2018
1 parent ac74cf7 commit 2b1c1d7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ports/geckolib/glue.rs
Expand Up @@ -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]
Expand Down

0 comments on commit 2b1c1d7

Please sign in to comment.