Skip to content

Commit

Permalink
use std::string for skip messages (#1571)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmah42 authored Mar 8, 2023
1 parent adb0d3d commit 060d762
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions include/benchmark/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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_; }
Expand Down
6 changes: 2 additions & 4 deletions src/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down

0 comments on commit 060d762

Please sign in to comment.