Skip to content

Instantly share code, notes, and snippets.

@jdm
Created May 31, 2013 20:06
Show Gist options
  • Save jdm/5687618 to your computer and use it in GitHub Desktop.
Save jdm/5687618 to your computer and use it in GitHub Desktop.
diff --git a/src/components/servo-util/tree.rs b/src/components/servo-util/tree.rs
index 23b8ca8..09a4070 100644
--- a/src/components/servo-util/tree.rs
+++ b/src/components/servo-util/tree.rs
@@ -132,6 +132,7 @@ impl<NR:TreeNodeRef<N>,N:TreeNode<NR>> TreeUtils for NR {
}
}
+ #[inline(always)]
fn each_child(&self, callback: &fn(NR) -> bool) -> bool {
let mut maybe_current = self.with_base(|n| n.first_child());
while !maybe_current.is_none() {
diff --git a/src/components/servo/dom/node.rs b/src/components/servo/dom/node.rs
index 5ae3656..88b6f70 100644
--- a/src/components/servo/dom/node.rs
+++ b/src/components/servo/dom/node.rs
@@ -250,9 +250,11 @@ impl AbstractNode {
// NB: You must not call these if you are not layout. We should do something with scoping to
// ensure this.
+ #[inline(always)]
pub fn layout_data(self) -> @mut LayoutData {
self.with_base(|b| b.layout_data.get())
}
+ #[inline(always)]
pub fn has_layout_data(self) -> bool {
self.with_base(|b| b.layout_data.is_some())
}
diff --git a/src/components/servo/layout/flow.rs b/src/components/servo/layout/flow.rs
index b28f118..88d4325 100644
--- a/src/components/servo/layout/flow.rs
+++ b/src/components/servo/layout/flow.rs
@@ -105,6 +105,7 @@ impl FlowData {
}
impl TreeNodeRef<FlowData> for FlowContext {
+ #[inline(always)]
fn with_base<R>(&self, callback: &fn(&FlowData) -> R) -> R {
match *self {
AbsoluteFlow(info) => callback(info),
@@ -119,6 +120,7 @@ impl TreeNodeRef<FlowData> for FlowContext {
TableFlow(info) => callback(info)
}
}
+ #[inline(always)]
fn with_mut_base<R>(&self, callback: &fn(&mut FlowData) -> R) -> R {
match *self {
AbsoluteFlow(info) => callback(info),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment