about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-08-16 23:14:55 -0700
committerBrian Anderson <banderson@mozilla.com>2013-08-23 21:19:59 -0700
commit30a7a5b8fa0f0c6262322d353020ff556708082e (patch)
treef35e3f0b3b2f0dd8baad3d447a1c50bc33ba5909 /src/libstd/rt
parent4c75d36d0e81508d4e7614104abb44fa19179c03 (diff)
downloadrust-30a7a5b8fa0f0c6262322d353020ff556708082e.tar.gz
rust-30a7a5b8fa0f0c6262322d353020ff556708082e.zip
Define cfg(rtopt) when optimizing. Turn off runtime sanity checks
Naturally, and sadly, turning off sanity checks in the runtime is
a noticable performance win. The particular test I'm running goes from
~1.5 s to ~1.3s.

Sanity checks are turned *on* when not optimizing, or when cfg
includes `rtdebug` or `rtassert`.
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/util.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs
index f2ede8872c2..c3f5b11a930 100644
--- a/src/libstd/rt/util.rs
+++ b/src/libstd/rt/util.rs
@@ -19,6 +19,9 @@ use unstable::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
 #[cfg(target_os="macos")]
 use unstable::running_on_valgrind;
 
+// Indicates whether we should perform expensive sanity checks, including rtassert!
+pub static ENFORCE_SANITY: bool = !cfg!(rtopt) || cfg!(rtdebug) || cfg!(rtassert);
+
 /// Get the number of cores available
 pub fn num_cpus() -> uint {
     #[fixed_stack_segment]; #[inline(never)];