Avoid unnecessary copying and allocation in ExecutorBarrier::WhenDone().

Previously the code would make a copy of the `done_cb_` and update the status
on a successful completion, neither of which is necessary, and both of which
showed up in trace amounts in profiling.

PiperOrigin-RevId: 179970701
This commit is contained in:
Derek Murray 2017-12-22 15:39:18 -08:00 committed by TensorFlower Gardener
parent 46ee1521bf
commit f10a598e34

View File

@ -202,11 +202,12 @@ class ExecutorBarrier {
// below.
if (--pending_ == 0) {
CHECK(done_cb_ != nullptr);
done = done_cb_;
done_cb_ = nullptr;
std::swap(done, done_cb_);
}
status = status_;
if (!status_.ok()) {
status = status_;
}
}
if (error) {