Commit e3f57750 authored by Shai Szulanski's avatar Shai Szulanski Committed by Facebook GitHub Bot

Use fold expression in CancellationToken::merge

Summary: Avoids temporary array

Reviewed By: yfeldblum

Differential Revision: D31547083

fbshipit-source-id: e8c8246145428079a00999da7b3d2c4f59105300
parent c47d0c77
......@@ -21,8 +21,6 @@
#include <glog/logging.h>
#include <folly/Utility.h>
namespace folly {
namespace detail {
......@@ -384,9 +382,7 @@ inline FixedMergingCancellationState<N>::FixedMergingCancellationState(
template <typename... Ts>
inline CancellationToken CancellationToken::merge(Ts&&... tokens) {
std::array<bool, sizeof...(Ts)> cancellable{{tokens.canBeCancelled()...}};
bool canBeCancelled =
std::any_of(cancellable.begin(), cancellable.end(), identity);
bool canBeCancelled = (tokens.canBeCancelled() || ...);
return canBeCancelled
? CancellationToken(
detail::FixedMergingCancellationState<sizeof...(Ts)>::create(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment