From 97814dd5469b22d91e6eb97f7ea5aa94eae449da Mon Sep 17 00:00:00 2001 From: blyxyas Date: Mon, 29 Jan 2024 01:33:55 +0100 Subject: [PATCH 1/2] Check pre-selfprofile if `self.prof.enabled()` is true --- compiler/rustc_session/src/utils.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs index f76c69af526e9..707714fdd5607 100644 --- a/compiler/rustc_session/src/utils.rs +++ b/compiler/rustc_session/src/utils.rs @@ -9,7 +9,11 @@ impl Session { } /// Used by `-Z self-profile`. pub fn time(&self, what: &'static str, f: impl FnOnce() -> R) -> R { - self.prof.verbose_generic_activity(what).run(f) + if self.prof.enabled() { + return self.prof.verbose_generic_activity(what).run(f) + } else { + return f() + } } } From 0939b866904feab7ded724909c207dec8e4f83c3 Mon Sep 17 00:00:00 2001 From: blyxyas Date: Mon, 29 Jan 2024 13:03:12 +0100 Subject: [PATCH 2/2] tidy --- compiler/rustc_session/src/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs index 707714fdd5607..a84f6bc66a888 100644 --- a/compiler/rustc_session/src/utils.rs +++ b/compiler/rustc_session/src/utils.rs @@ -10,9 +10,9 @@ impl Session { /// Used by `-Z self-profile`. pub fn time(&self, what: &'static str, f: impl FnOnce() -> R) -> R { if self.prof.enabled() { - return self.prof.verbose_generic_activity(what).run(f) + return self.prof.verbose_generic_activity(what).run(f); } else { - return f() + return f(); } } }