use std::string for skip messages (#1571)

This commit is contained in:
dominic 2023-03-08 18:57:19 +00:00 committed by GitHub
parent adb0d3d0bf
commit 060d762d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -760,7 +760,7 @@ class BENCHMARK_EXPORT State {
// the current scope immediately. If the function is called from within // the current scope immediately. If the function is called from within
// the 'KeepRunning()' loop the current iteration will finish. It is the users // the 'KeepRunning()' loop the current iteration will finish. It is the users
// responsibility to exit the scope as needed. // 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 // REQUIRES: 'SkipWithMessage(...)' or 'SkipWithError(...)' has not been
// called previously by the current thread. // 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 current scope immediately. If the function is called from within
// the 'KeepRunning()' loop the current iteration will finish. It is the users // the 'KeepRunning()' loop the current iteration will finish. It is the users
// responsibility to exit the scope as needed. // 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. // Returns true if 'SkipWithMessage(...)' or 'SkipWithError(...)' was called.
bool skipped() const { return internal::NotSkipped != skipped_; } bool skipped() const { return internal::NotSkipped != skipped_; }

View File

@ -236,8 +236,7 @@ void State::ResumeTiming() {
} }
} }
void State::SkipWithMessage(const char* msg) { void State::SkipWithMessage(const std::string& msg) {
BM_CHECK(msg);
skipped_ = internal::SkippedWithMessage; skipped_ = internal::SkippedWithMessage;
{ {
MutexLock l(manager_->GetBenchmarkMutex()); MutexLock l(manager_->GetBenchmarkMutex());
@ -250,8 +249,7 @@ void State::SkipWithMessage(const char* msg) {
if (timer_->running()) timer_->StopTimer(); if (timer_->running()) timer_->StopTimer();
} }
void State::SkipWithError(const char* msg) { void State::SkipWithError(const std::string& msg) {
BM_CHECK(msg);
skipped_ = internal::SkippedWithError; skipped_ = internal::SkippedWithError;
{ {
MutexLock l(manager_->GetBenchmarkMutex()); MutexLock l(manager_->GetBenchmarkMutex());