]> git.lizzy.rs Git - rust.git/commitdiff
Disable the self-profiler unless the `-Z self-profile` flag is set
authorWesley Wiser <wwiser@gmail.com>
Thu, 22 Nov 2018 17:56:15 +0000 (12:56 -0500)
committerWesley Wiser <wwiser@gmail.com>
Thu, 22 Nov 2018 17:56:15 +0000 (12:56 -0500)
Related to #51648

src/librustc/session/mod.rs

index d688d93b80842c6734841c7b4951b2bb7db6460a..1187c53305d1c36956df23f32f5c9606ff28c2c2 100644 (file)
@@ -826,8 +826,10 @@ pub fn incr_comp_session_dir_opt(&self) -> Option<cell::Ref<'_, PathBuf>> {
     }
 
     pub fn profiler<F: FnOnce(&mut SelfProfiler) -> ()>(&self, f: F) {
-        let mut profiler = self.self_profiling.borrow_mut();
-        f(&mut profiler);
+        if self.opts.debugging_opts.self_profile {
+            let mut profiler = self.self_profiling.borrow_mut();
+            f(&mut profiler);
+        }
     }
 
     pub fn print_profiler_results(&self) {