@@ -185,25 +185,17 @@ class TimeTraceScope {
185185 TimeTraceScope (TimeTraceScope &&) = delete ;
186186 TimeTraceScope &operator =(TimeTraceScope &&) = delete ;
187187
188- TimeTraceScope (StringRef Name) {
189- if (getTimeTraceProfilerInstance () != nullptr )
190- Entry = timeTraceProfilerBegin (Name, StringRef (" " ));
191- }
192- TimeTraceScope (StringRef Name, StringRef Detail) {
193- if (getTimeTraceProfilerInstance () != nullptr )
194- Entry = timeTraceProfilerBegin (Name, Detail);
195- }
196- TimeTraceScope (StringRef Name, llvm::function_ref<std::string()> Detail) {
197- if (getTimeTraceProfilerInstance () != nullptr )
198- Entry = timeTraceProfilerBegin (Name, Detail);
199- }
188+ TimeTraceScope (StringRef Name)
189+ : Entry(timeTraceProfilerBegin(Name, StringRef())) {}
190+ TimeTraceScope (StringRef Name, StringRef Detail)
191+ : Entry(timeTraceProfilerBegin(Name, Detail)) {}
192+ TimeTraceScope (StringRef Name, llvm::function_ref<std::string()> Detail)
193+ : Entry(timeTraceProfilerBegin(Name, Detail)) {}
200194 TimeTraceScope (StringRef Name,
201- llvm::function_ref<TimeTraceMetadata()> Metadata) {
202- if (getTimeTraceProfilerInstance () != nullptr )
203- Entry = timeTraceProfilerBegin (Name, Metadata);
204- }
195+ llvm::function_ref<TimeTraceMetadata()> Metadata)
196+ : Entry(timeTraceProfilerBegin(Name, Metadata)) {}
205197 ~TimeTraceScope () {
206- if (getTimeTraceProfilerInstance () != nullptr )
198+ if (Entry )
207199 timeTraceProfilerEnd (Entry);
208200 }
209201
0 commit comments