From 4141b776c279431d70141e32af32d1df184e31e1 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 15 May 2014 19:43:04 +0100 Subject: [PATCH] =?UTF-8?q?Optimize=20CSS=C2=A0error=20logging:=20check=20?= =?UTF-8?q?log=20level=20before=20task-local=20silencing.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/style/errors.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/style/errors.rs b/src/components/style/errors.rs index b8d811aebd1..215512c8e42 100644 --- a/src/components/style/errors.rs +++ b/src/components/style/errors.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + use cssparser::ast::{SyntaxError, SourceLocation}; @@ -25,9 +26,12 @@ impl>> Iterator for ErrorLoggerIterator /// Set a `RUST_LOG=style::errors` environment variable /// to log CSS parse errors to stderr. pub fn log_css_error(location: SourceLocation, message: &str) { - // TODO eventually this will got into a "web console" or something. - if silence_errors.get().is_none() { - info!("{:u}:{:u} {:s}", location.line, location.column, message) + // Check this first as it’s cheaper than local_data. + if log_enabled!(::log::INFO) { + if silence_errors.get().is_none() { + // TODO eventually this will got into a "web console" or something. + info!("{:u}:{:u} {:s}", location.line, location.column, message) + } } }