Avoid debug serialization of PropertyDeclaration & co in release builds.

In total, this PR saves ~60k.

The conditional compilation on the _Debug FFI function eliminates one
of the ToCss variants, eliminating 54.4k, as well as a bunch of other
<1k functions. Removing the public trait implementation of Debug for the
font metrics provider eliminates the last Debug impl from stylo.

MozReview-Commit-ID: nIfQ3sy4OW
This commit is contained in:
Bobby Holley 2018-01-15 15:23:48 -08:00
parent 2ff3e119fa
commit 9a8821a1b0
2 changed files with 8 additions and 2 deletions

View file

@ -12,7 +12,6 @@ use context::SharedStyleContext;
use logical_geometry::WritingMode; use logical_geometry::WritingMode;
use media_queries::Device; use media_queries::Device;
use properties::style_structs::Font; use properties::style_structs::Font;
use std::fmt;
/// Represents the font metrics that style needs from a font to compute the /// Represents the font metrics that style needs from a font to compute the
/// value of certain CSS units like `ex`. /// value of certain CSS units like `ex`.
@ -35,7 +34,7 @@ pub enum FontMetricsQueryResult {
} }
/// A trait used to represent something capable of providing us font metrics. /// A trait used to represent something capable of providing us font metrics.
pub trait FontMetricsProvider: fmt::Debug { pub trait FontMetricsProvider {
/// Obtain the metrics for given font family. /// Obtain the metrics for given font family.
/// ///
/// TODO: We could make this take the full list, I guess, and save a few /// TODO: We could make this take the full list, I guess, and save a few

View file

@ -1438,6 +1438,7 @@ macro_rules! impl_basic_rule_funcs_without_getter {
debug: $debug:ident, debug: $debug:ident,
to_css: $to_css:ident, to_css: $to_css:ident,
} => { } => {
#[cfg(debug_assertions)]
#[no_mangle] #[no_mangle]
pub extern "C" fn $debug(rule: &$raw_type, result: *mut nsACString) { pub extern "C" fn $debug(rule: &$raw_type, result: *mut nsACString) {
read_locked_arc(rule, |rule: &$rule_type| { read_locked_arc(rule, |rule: &$rule_type| {
@ -1445,6 +1446,12 @@ macro_rules! impl_basic_rule_funcs_without_getter {
}) })
} }
#[cfg(not(debug_assertions))]
#[no_mangle]
pub extern "C" fn $debug(_: &$raw_type, _: *mut nsACString) {
unreachable!()
}
#[no_mangle] #[no_mangle]
pub extern "C" fn $to_css(rule: &$raw_type, result: *mut nsAString) { pub extern "C" fn $to_css(rule: &$raw_type, result: *mut nsAString) {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;