diff options
author | Glenn Watson <gw@intuitionlibrary.com> | 2014-09-05 08:37:42 +1000 |
---|---|---|
committer | Glenn Watson <gw@intuitionlibrary.com> | 2014-09-05 09:41:43 +1000 |
commit | a0854080ccbcdd1e1af7ef35e04865a436fb70be (patch) | |
tree | 521dded4ce53e6299027943c6ecc4ffde22a4071 | |
parent | acedb166707aa2e8fd02e6c7d943147394c34609 (diff) | |
download | servo-a0854080ccbcdd1e1af7ef35e04865a436fb70be.tar.gz servo-a0854080ccbcdd1e1af7ef35e04865a436fb70be.zip |
Change scope macro to be a no-op in release builds.
-rw-r--r-- | src/components/layout/block.rs | 8 | ||||
-rw-r--r-- | src/components/layout/inline.rs | 7 | ||||
-rw-r--r-- | src/components/layout/layout.rs | 4 | ||||
-rw-r--r-- | src/components/layout/layout_debug.rs | 14 | ||||
-rw-r--r-- | src/components/layout/layout_task.rs | 2 |
5 files changed, 25 insertions, 10 deletions
diff --git a/src/components/layout/block.rs b/src/components/layout/block.rs index 269dbccdb76..b1e9bb2c685 100644 --- a/src/components/layout/block.rs +++ b/src/components/layout/block.rs @@ -811,7 +811,7 @@ impl BlockFlow { pub fn assign_block_size_block_base<'a>(&mut self, layout_context: &'a LayoutContext<'a>, margins_may_collapse: MarginsMayCollapseFlag) { - let _scope = layout_debug::Scope::new(format!("assign_block_size_block_base {:s}", self.base.debug_id())); + let _scope = layout_debug_scope!("assign_block_size_block_base {:s}", self.base.debug_id()); // Our current border-box position. let mut cur_b = Au(0); @@ -1059,7 +1059,7 @@ impl BlockFlow { /// /// It does not calculate the block-size of the flow itself. pub fn assign_block_size_float<'a>(&mut self, ctx: &'a LayoutContext<'a>) { - let _scope = layout_debug::Scope::new(format!("assign_block_size_float {:s}", self.base.debug_id())); + let _scope = layout_debug_scope!("assign_block_size_float {:s}", self.base.debug_id()); let mut floats = Floats::new(self.fragment.style.writing_mode); for kid in self.base.child_iter() { @@ -1457,7 +1457,7 @@ impl Flow for BlockFlow { /// /// TODO(pcwalton): Inline blocks. fn bubble_inline_sizes(&mut self, _: &LayoutContext) { - let _scope = layout_debug::Scope::new(format!("block::bubble_inline_sizes {:s}", self.base.debug_id())); + let _scope = layout_debug_scope!("bubble_inline_sizes {:s}", self.base.debug_id()); let mut flags = self.base.flags; flags.set_has_left_floated_descendants(false); @@ -1503,7 +1503,7 @@ impl Flow for BlockFlow { /// Dual fragments consume some inline-size first, and the remainder is assigned to all child (block) /// contexts. fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug::Scope::new(format!("block::assign_inline_sizes {:s}", self.base.debug_id())); + let _scope = layout_debug_scope!("block::assign_inline_sizes {:s}", self.base.debug_id()); debug!("assign_inline_sizes({}): assigning inline_size for flow", if self.is_float() { diff --git a/src/components/layout/inline.rs b/src/components/layout/inline.rs index 6fc05e00cab..6c22b25746e 100644 --- a/src/components/layout/inline.rs +++ b/src/components/layout/inline.rs @@ -907,7 +907,7 @@ impl Flow for InlineFlow { } fn bubble_inline_sizes(&mut self, _: &LayoutContext) { - let _scope = layout_debug::Scope::new(format!("inline::bubble_inline_sizes {:s}", self.base.debug_id())); + let _scope = layout_debug_scope!("inline::bubble_inline_sizes {:s}", self.base.debug_id()); let writing_mode = self.base.writing_mode; for kid in self.base.child_iter() { @@ -934,7 +934,7 @@ impl Flow for InlineFlow { /// Recursively (top-down) determines the actual inline-size of child contexts and fragments. When called /// on this context, the context has had its inline-size set by the parent context. fn assign_inline_sizes(&mut self, _: &LayoutContext) { - let _scope = layout_debug::Scope::new(format!("inline::assign_inline_sizes {:s}", self.base.debug_id())); + let _scope = layout_debug_scope!("inline::assign_inline_sizes {:s}", self.base.debug_id()); // Initialize content fragment inline-sizes if they haven't been initialized already. // @@ -964,8 +964,7 @@ impl Flow for InlineFlow { /// Calculate and set the block-size of this flow. See CSS 2.1 § 10.6.1. fn assign_block_size(&mut self, ctx: &LayoutContext) { - let _scope = layout_debug::Scope::new(format!("inline::assign_block_size {:s}", self.base.debug_id())); - debug!("assign_block_size_inline: assigning block_size for flow"); + let _scope = layout_debug_scope!("inline::assign_block_size {:s}", self.base.debug_id()); // Divide the fragments into lines. // diff --git a/src/components/layout/layout.rs b/src/components/layout/layout.rs index 51f82654323..a9ee00319f7 100644 --- a/src/components/layout/layout.rs +++ b/src/components/layout/layout.rs @@ -35,6 +35,9 @@ extern crate libc; extern crate sync; extern crate url; +// Listed first because of macro definitions +pub mod layout_debug; + pub mod block; pub mod construct; pub mod context; @@ -43,7 +46,6 @@ pub mod flow; pub mod flow_list; pub mod flow_ref; pub mod fragment; -pub mod layout_debug; pub mod layout_task; pub mod inline; pub mod model; diff --git a/src/components/layout/layout_debug.rs b/src/components/layout/layout_debug.rs index bf4cbbfca2a..58db599c9e2 100644 --- a/src/components/layout/layout_debug.rs +++ b/src/components/layout/layout_debug.rs @@ -5,6 +5,8 @@ //! Supports writing a trace file created during each layout scope //! that can be viewed by an external tool to make layout debugging easier. +#![macro_escape] + use flow_ref::FlowRef; use serialize::json; use std::cell::RefCell; @@ -17,6 +19,17 @@ static mut DEBUG_ID_COUNTER: AtomicUint = INIT_ATOMIC_UINT; pub struct Scope; +#[macro_export] +macro_rules! layout_debug_scope( + ($($arg:tt)*) => ( + if cfg!(not(ndebug)) { + layout_debug::Scope::new(format!($($arg)*)) + } else { + layout_debug::Scope + } + ) +) + #[deriving(Encodable)] struct ScopeData { name: String, @@ -59,6 +72,7 @@ impl Scope { } } +#[cfg(not(ndebug))] impl Drop for Scope { fn drop(&mut self) { let maybe_refcell = state_key.get(); diff --git a/src/components/layout/layout_task.rs b/src/components/layout/layout_task.rs index 93b49652678..582a26c37e9 100644 --- a/src/components/layout/layout_task.rs +++ b/src/components/layout/layout_task.rs @@ -531,7 +531,7 @@ impl LayoutTask { fn solve_constraints<'a>(&mut self, layout_root: &mut Flow, layout_context: &'a LayoutContext<'a>) { - let _scope = layout_debug::Scope::new("solve_constraints".to_string()); + let _scope = layout_debug_scope!("solve_constraints"); if layout_context.shared.opts.bubble_inline_sizes_separately { let mut traversal = BubbleISizesTraversal { |