Skip to content

Commit

Permalink
Auto merge of #19451 - emilio:inlining-is-fun, r=upsuper
Browse files Browse the repository at this point in the history
style: Inline some things that should never ever appear in a profile.

<!-- 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/19451)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Dec 1, 2017
2 parents bca8951 + 2bbeda9 commit f7aa22a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions components/style/gecko/wrapper.rs
Expand Up @@ -211,6 +211,7 @@ impl<'ln> GeckoNode<'ln> {

/// WARNING: This logic is duplicated in Gecko's FlattenedTreeParentIsParent.
/// Make sure to mirror any modifications in both places.
#[inline]
fn flattened_tree_parent_is_parent(&self) -> bool {
use gecko_bindings::structs::*;
let flags = self.flags();
Expand All @@ -236,6 +237,7 @@ impl<'ln> GeckoNode<'ln> {
true
}

#[inline]
fn flattened_tree_parent(&self) -> Option<Self> {
let fast_path = self.flattened_tree_parent_is_parent();
debug_assert!(fast_path == unsafe { bindings::Gecko_FlattenedTreeParentIsParent(self.0) });
Expand All @@ -246,6 +248,7 @@ impl<'ln> GeckoNode<'ln> {
}
}

#[inline]
fn contains_non_whitespace_content(&self) -> bool {
unsafe { Gecko_IsSignificantChild(self.0, true, false) }
}
Expand Down
8 changes: 6 additions & 2 deletions components/style/properties/declaration_block.rs
Expand Up @@ -91,7 +91,7 @@ pub struct DeclarationImportanceIterator<'a> {
}

impl<'a> DeclarationImportanceIterator<'a> {
/// Constructor
/// Constructor.
pub fn new(declarations: &'a [PropertyDeclaration], important: &'a SmallBitVec) -> Self {
DeclarationImportanceIterator {
iter: declarations.iter().zip(important.iter()),
Expand All @@ -102,17 +102,20 @@ impl<'a> DeclarationImportanceIterator<'a> {
impl<'a> Iterator for DeclarationImportanceIterator<'a> {
type Item = (&'a PropertyDeclaration, Importance);

#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.iter.next().map(|(decl, important)|
(decl, if important { Importance::Important } else { Importance::Normal }))
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
}
}

impl<'a> DoubleEndedIterator for DeclarationImportanceIterator<'a> {
#[inline(always)]
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(|(decl, important)|
(decl, if important { Importance::Important } else { Importance::Normal }))
Expand All @@ -123,7 +126,8 @@ impl<'a> DoubleEndedIterator for DeclarationImportanceIterator<'a> {
pub struct NormalDeclarationIterator<'a>(DeclarationImportanceIterator<'a>);

impl<'a> NormalDeclarationIterator<'a> {
/// Constructor
/// Constructor.
#[inline]
pub fn new(declarations: &'a [PropertyDeclaration], important: &'a SmallBitVec) -> Self {
NormalDeclarationIterator(
DeclarationImportanceIterator::new(declarations, important)
Expand Down
7 changes: 4 additions & 3 deletions components/style/properties/properties.mako.rs
Expand Up @@ -3129,6 +3129,9 @@ pub fn cascade(
) -> Arc<ComputedValues> {
debug_assert_eq!(parent_style.is_some(), parent_style_ignoring_first_line.is_some());
let empty = SmallBitVec::new();

let property_restriction = pseudo.and_then(|p| p.property_restriction());

let iter_declarations = || {
rule_node.self_and_ancestors().flat_map(|node| {
let cascade_level = node.cascade_level();
Expand All @@ -3142,8 +3145,6 @@ pub fn cascade(
};
let node_importance = node.importance();

let property_restriction = pseudo.and_then(|p| p.property_restriction());

declarations
// Yield declarations later in source order (with more precedence) first.
.rev()
Expand All @@ -3168,6 +3169,7 @@ pub fn cascade(
})
})
};

apply_declarations(
device,
pseudo,
Expand All @@ -3187,7 +3189,6 @@ pub fn cascade(

/// NOTE: This function expects the declaration with more priority to appear
/// first.
#[allow(unused_mut)] // conditionally compiled code for "position"
pub fn apply_declarations<'a, F, I>(
device: &Device,
pseudo: Option<<&PseudoElement>,
Expand Down

0 comments on commit f7aa22a

Please sign in to comment.