Chromium Code Reviews| Index: cc/debug/micro_benchmark_controller.cc |
| diff --git a/cc/debug/micro_benchmark_controller.cc b/cc/debug/micro_benchmark_controller.cc |
| index a0dc306612fa77c0d65a0c45ce3adf488eaf64ed..c7ee5022c40074ff832571bad72a5a03b1bf868f 100644 |
| --- a/cc/debug/micro_benchmark_controller.cc |
| +++ b/cc/debug/micro_benchmark_controller.cc |
| @@ -37,16 +37,6 @@ scoped_ptr<MicroBenchmark> CreateBenchmark( |
| return nullptr; |
| } |
| -class IsDonePredicate { |
| - public: |
| - typedef const MicroBenchmark* argument_type; |
| - typedef bool result_type; |
| - |
| - result_type operator()(argument_type benchmark) const { |
| - return benchmark->IsDone(); |
| - } |
| -}; |
| - |
| } // namespace |
| MicroBenchmarkController::MicroBenchmarkController(LayerTreeHost* host) |
| @@ -85,23 +75,20 @@ int MicroBenchmarkController::GetNextIdAndIncrement() { |
| bool MicroBenchmarkController::SendMessage(int id, |
| scoped_ptr<base::Value> value) { |
| - for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin(); |
| - it != benchmarks_.end(); |
| - ++it) { |
| - if ((*it)->id() == id) |
| - return (*it)->ProcessMessage(value.Pass()); |
| - } |
| - return false; |
| + auto it = std::find_if(benchmarks_.begin(), benchmarks_.end(), |
| + [id](const scoped_ptr<MicroBenchmark>& benchmark) { |
| + return benchmark->id() == id; |
| + }); |
| + return it != benchmarks_.end() ? (*it)->ProcessMessage(value.Pass()) : false; |
|
danakj
2015/11/17 23:49:41
can you do this with an early out instead on if it
vmpstr
2015/11/18 00:08:46
Done.
|
| } |
| void MicroBenchmarkController::ScheduleImplBenchmarks( |
| LayerTreeHostImpl* host_impl) { |
| - for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin(); |
| - it != benchmarks_.end(); |
| - ++it) { |
| + for (const auto& benchmark : benchmarks_) { |
| scoped_ptr<MicroBenchmarkImpl> benchmark_impl; |
| - if (!(*it)->ProcessedForBenchmarkImpl()) { |
| - benchmark_impl = (*it)->GetBenchmarkImpl(main_controller_task_runner_); |
| + if (!benchmark->ProcessedForBenchmarkImpl()) { |
| + benchmark_impl = |
| + benchmark->GetBenchmarkImpl(main_controller_task_runner_); |
| } |
| if (benchmark_impl.get()) |
| @@ -110,11 +97,9 @@ void MicroBenchmarkController::ScheduleImplBenchmarks( |
| } |
| void MicroBenchmarkController::DidUpdateLayers() { |
| - for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin(); |
| - it != benchmarks_.end(); |
| - ++it) { |
| - if (!(*it)->IsDone()) |
| - (*it)->DidUpdateLayers(host_); |
| + for (const auto& benchmark : benchmarks_) { |
| + if (!benchmark->IsDone()) |
| + benchmark->DidUpdateLayers(host_); |
| } |
| CleanUpFinishedBenchmarks(); |
| @@ -122,7 +107,10 @@ void MicroBenchmarkController::DidUpdateLayers() { |
| void MicroBenchmarkController::CleanUpFinishedBenchmarks() { |
| benchmarks_.erase( |
| - benchmarks_.partition(std::not1(IsDonePredicate())), |
| + std::remove_if(benchmarks_.begin(), benchmarks_.end(), |
| + [](const scoped_ptr<MicroBenchmark>& benchmark) { |
| + return benchmark->IsDone(); |
| + }), |
| benchmarks_.end()); |
| } |