Skip to content

Commit a9c15b1

Browse files
committed
some fixes
std::function is already nullptr by default. thus, there is no need to initialize its by by nullptr manually.
1 parent 2cd16a5 commit a9c15b1

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

include/benchmark/benchmark.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,6 @@ class BENCHMARK_EXPORT Benchmark {
11621162
//
11631163
// The callback will be passed a State object, which includes the number
11641164
// of threads, thread-index, benchmark arguments, etc.
1165-
//
1166-
// The callback must not be NULL or self-deleting.
11671165
Benchmark* Setup(callback_function&&);
11681166
Benchmark* Setup(const callback_function&);
11691167
Benchmark* Teardown(callback_function&&);

src/benchmark_api_internal.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ BenchmarkInstance::BenchmarkInstance(Benchmark* benchmark, int family_idx,
2727
min_time_(benchmark_.min_time_),
2828
min_warmup_time_(benchmark_.min_warmup_time_),
2929
iterations_(benchmark_.iterations_),
30-
threads_(thread_count) {
30+
threads_(thread_count),
31+
setup_(benchmark_.setup_),
32+
teardown_(benchmark_.teardown_) {
3133
name_.function_name = benchmark_.name_;
3234

3335
size_t arg_i = 0;
@@ -84,9 +86,6 @@ BenchmarkInstance::BenchmarkInstance(Benchmark* benchmark, int family_idx,
8486
if (!benchmark_.thread_counts_.empty()) {
8587
name_.threads = StrFormat("threads:%d", threads_);
8688
}
87-
88-
setup_ = benchmark_.setup_;
89-
teardown_ = benchmark_.teardown_;
9089
}
9190

9291
State BenchmarkInstance::Run(

src/benchmark_api_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class BenchmarkInstance {
6868
IterationCount iterations_;
6969
int threads_; // Number of concurrent threads to us
7070

71-
callback_function setup_ = nullptr;
72-
callback_function teardown_ = nullptr;
71+
callback_function setup_;
72+
callback_function teardown_;
7373
};
7474

7575
bool FindBenchmarksInternal(const std::string& re,

src/benchmark_register.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ Benchmark::Benchmark(const std::string& name)
224224
use_real_time_(false),
225225
use_manual_time_(false),
226226
complexity_(oNone),
227-
complexity_lambda_(nullptr),
228-
setup_(nullptr),
229-
teardown_(nullptr) {
227+
complexity_lambda_(nullptr) {
230228
ComputeStatistics("mean", StatisticsMean);
231229
ComputeStatistics("median", StatisticsMedian);
232230
ComputeStatistics("stddev", StatisticsStdDev);

0 commit comments

Comments
 (0)