From 060d762d6129ab19af8558bc76983ea82cb6b050 Mon Sep 17 00:00:00 2001 From: dominic <510002+dmah42@users.noreply.github.com> Date: Wed, 8 Mar 2023 18:57:19 +0000 Subject: [PATCH] use std::string for skip messages (#1571) --- include/benchmark/benchmark.h | 4 ++-- src/benchmark.cc | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index bb29c73d..783fcd8e 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -760,7 +760,7 @@ class BENCHMARK_EXPORT State { // the current scope immediately. If the function is called from within // the 'KeepRunning()' loop the current iteration will finish. It is the users // responsibility to exit the scope as needed. - void SkipWithMessage(const char* msg); + void SkipWithMessage(const std::string& msg); // REQUIRES: 'SkipWithMessage(...)' or 'SkipWithError(...)' has not been // called previously by the current thread. @@ -781,7 +781,7 @@ class BENCHMARK_EXPORT State { // the current scope immediately. If the function is called from within // the 'KeepRunning()' loop the current iteration will finish. It is the users // responsibility to exit the scope as needed. - void SkipWithError(const char* msg); + void SkipWithError(const std::string& msg); // Returns true if 'SkipWithMessage(...)' or 'SkipWithError(...)' was called. bool skipped() const { return internal::NotSkipped != skipped_; } diff --git a/src/benchmark.cc b/src/benchmark.cc index f06f3684..1937eea3 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -236,8 +236,7 @@ void State::ResumeTiming() { } } -void State::SkipWithMessage(const char* msg) { - BM_CHECK(msg); +void State::SkipWithMessage(const std::string& msg) { skipped_ = internal::SkippedWithMessage; { MutexLock l(manager_->GetBenchmarkMutex()); @@ -250,8 +249,7 @@ void State::SkipWithMessage(const char* msg) { if (timer_->running()) timer_->StopTimer(); } -void State::SkipWithError(const char* msg) { - BM_CHECK(msg); +void State::SkipWithError(const std::string& msg) { skipped_ = internal::SkippedWithError; { MutexLock l(manager_->GetBenchmarkMutex());