From eb2b25dd6d38157213742b048fad63fa4ceec691 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 28 Aug 2013 01:33:48 -0700 Subject: Refactor the logging system for fewer allocations This lifts various restrictions on the runtime, for example the character limit when logging a message. Right now the old debug!-style macros still involve allocating (because they use fmt! syntax), but the new debug2! macros don't involve allocating at all (unless the formatter for a type requires allocation. --- src/libsyntax/ext/expand.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 64f30803ca7..80cb9424fa1 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -813,13 +813,17 @@ pub fn std_macros() -> @str { ($lvl:expr, $arg:expr) => ({ let lvl = $lvl; if lvl <= __log_level() { - ::std::logging::log(lvl, fmt!(\"%?\", $arg)) + format_args!(|args| { + ::std::logging::log(lvl, args) + }, \"{}\", fmt!(\"%?\", $arg)) } }); ($lvl:expr, $($arg:expr),+) => ({ let lvl = $lvl; if lvl <= __log_level() { - ::std::logging::log(lvl, fmt!($($arg),+)) + format_args!(|args| { + ::std::logging::log(lvl, args) + }, \"{}\", fmt!($($arg),+)) } }) ) @@ -834,7 +838,9 @@ pub fn std_macros() -> @str { ($lvl:expr, $($arg:tt)+) => ({ let lvl = $lvl; if lvl <= __log_level() { - ::std::logging::log(lvl, format!($($arg)+)) + format_args!(|args| { + ::std::logging::log(lvl, args) + }, $($arg)+) } }) ) -- cgit 1.4.1-3-g733a5