Skip to content

Commit

Permalink
Reformat with new whitespace penalty
Browse files Browse the repository at this point in the history
Summary: Applying the formatting change from D67051995

Reviewed By: yfeldblum

Differential Revision: D67051993

fbshipit-source-id: e07d73206f964e0c0e05f646162d3da91f3ad6fc
  • Loading branch information
Alexey Spiridonov authored and facebook-github-bot committed Dec 11, 2024
1 parent 048c8f0 commit abf77ba
Show file tree
Hide file tree
Showing 346 changed files with 4,125 additions and 3,395 deletions.
5 changes: 3 additions & 2 deletions folly/AtomicHashArray-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ AtomicHashArray<
}
DCHECK(relaxedLoadKey(*cell) != kEmptyKey_);
if (kLockedKey_ == acquireLoadKey(*cell)) {
detail::atomic_hash_spin_wait(
[&] { return kLockedKey_ == acquireLoadKey(*cell); });
detail::atomic_hash_spin_wait([&] {
return kLockedKey_ == acquireLoadKey(*cell);
});
}

const KeyT thisKey = acquireLoadKey(*cell);
Expand Down
5 changes: 3 additions & 2 deletions folly/AtomicHashMap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ AtomicHashMap<
ProbeFcn,
KeyConvertFcn>::AtomicHashMap(size_t finalSizeEst, const Config& config)
: kGrowthFrac_(
config.growthFactor < 0 ? 1.0f - config.maxLoadFactor
: config.growthFactor) {
config.growthFactor < 0
? 1.0f - config.maxLoadFactor
: config.growthFactor) {
CHECK(config.maxLoadFactor > 0.0f && config.maxLoadFactor < 1.0f);
subMaps_[0].store(
SubMap::create(finalSizeEst, config).release(),
Expand Down
5 changes: 3 additions & 2 deletions folly/AtomicHashMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,9 @@ class AtomicHashMap {
}

inline uint32_t recToIdx(value_type&& r, bool mayInsert = true) {
SimpleRetT ret = mayInsert ? insertInternal(r.first, std::move(r.second))
: findInternal(r.first);
SimpleRetT ret = mayInsert
? insertInternal(r.first, std::move(r.second))
: findInternal(r.first);
return encodeIndex(ret.i, ret.j);
}

Expand Down
5 changes: 3 additions & 2 deletions folly/AtomicLinkedList.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ class AtomicLinkedList {
AtomicLinkedList& operator=(const AtomicLinkedList&) = delete;
AtomicLinkedList(AtomicLinkedList&& other) noexcept = default;
AtomicLinkedList& operator=(AtomicLinkedList&& other) noexcept {
list_.reverseSweepAndAssign(
std::move(other.list_), [](Wrapper* node) { delete node; });
list_.reverseSweepAndAssign(std::move(other.list_), [](Wrapper* node) {
delete node;
});
return *this;
}

Expand Down
5 changes: 3 additions & 2 deletions folly/AtomicUnorderedMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,9 @@ struct AtomicUnorderedInsertMap {
/// http://functionalcpp.wordpress.com/2013/08/28/tuple-forwarding/).
template <class K, class V>
std::pair<const_iterator, bool> emplace(const K& key, V&& value) {
return findOrConstruct(
key, [&](void* raw) { new (raw) Value(std::forward<V>(value)); });
return findOrConstruct(key, [&](void* raw) {
new (raw) Value(std::forward<V>(value));
});
}

const_iterator find(const Key& key) const {
Expand Down
5 changes: 3 additions & 2 deletions folly/Benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,9 @@ void printResultComparison(
return rv; \
}), \
true); \
static void funName([[maybe_unused]] ::folly::UserCounters& counters \
FOLLY_PP_DETAIL_APPEND_VA_ARG(paramType paramName))
static void funName( \
[[maybe_unused]] ::folly::UserCounters& counters \
FOLLY_PP_DETAIL_APPEND_VA_ARG(paramType paramName))

/**
* Introduces a benchmark function with support for returning the actual
Expand Down
15 changes: 9 additions & 6 deletions folly/CancellationToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,19 @@ MergingCancellationState::MergingCancellationState(
CopyTag, size_t nCopy, const CancellationToken** copyToks)
: MergingCancellationState() {
for (size_t i = 0; i < nCopy; ++i, ++callbackEnd_) {
new (callbackEnd_)
CancellationCallback(*copyToks[i], [this] { requestCancellation(); });
new (callbackEnd_) CancellationCallback(*copyToks[i], [this] {
requestCancellation();
});
}
}

MergingCancellationState::MergingCancellationState(
MoveTag, size_t nMove, CancellationToken** moveToks)
: MergingCancellationState() {
for (size_t i = 0; i < nMove; ++i, ++callbackEnd_) {
new (callbackEnd_) CancellationCallback(
std::move(*moveToks[i]), [this] { requestCancellation(); });
new (callbackEnd_) CancellationCallback(std::move(*moveToks[i]), [this] {
requestCancellation();
});
}
}

Expand All @@ -288,8 +290,9 @@ MergingCancellationState::MergingCancellationState(
CancellationToken** moveToks)
: MergingCancellationState(CopyTag{}, nCopy, copyToks) {
for (size_t i = 0; i < nMove; ++i, ++callbackEnd_) {
new (callbackEnd_) CancellationCallback(
std::move(*moveToks[i]), [this] { requestCancellation(); });
new (callbackEnd_) CancellationCallback(std::move(*moveToks[i]), [this] {
requestCancellation();
});
}
}

Expand Down
7 changes: 4 additions & 3 deletions folly/ConcurrentSkipList-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ class SkipListNode {
}

template <typename NodeAlloc>
struct DestroyIsNoOp : StrictConjunction<
AllocatorHasTrivialDeallocate<NodeAlloc>,
std::is_trivially_destructible<SkipListNode>> {};
struct DestroyIsNoOp
: StrictConjunction<
AllocatorHasTrivialDeallocate<NodeAlloc>,
std::is_trivially_destructible<SkipListNode>> {};

// copy the head node to a new head node assuming lock acquired
SkipListNode* copyHead(SkipListNode* node) {
Expand Down
24 changes: 14 additions & 10 deletions folly/ConcurrentSkipList.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ class ConcurrentSkipList {
bool valid = true;
for (int layer = 0; valid && layer < nodeHeight; ++layer) {
pred = preds[layer];
DCHECK(pred != nullptr) << "layer=" << layer << " height=" << height()
<< " nodeheight=" << nodeHeight;
DCHECK(pred != nullptr)
<< "layer=" << layer << " height=" << height()
<< " nodeheight=" << nodeHeight;
succ = succs[layer];
if (pred != prevPred) {
guards[layer] = pred->acquireGuard();
Expand Down Expand Up @@ -414,8 +415,9 @@ class ConcurrentSkipList {
}
} while (node != nullptr);
}
return pred == head_.load(std::memory_order_relaxed) ? nullptr
: &pred->data();
return pred == head_.load(std::memory_order_relaxed)
? nullptr
: &pred->data();
}

static bool okToDelete(NodeType* candidate, int layer) {
Expand Down Expand Up @@ -665,10 +667,11 @@ class ConcurrentSkipList<T, Comp, NodeAlloc, MAX_HEIGHT>::Accessor {

// implements forward iterator concept.
template <typename ValT, typename NodeT>
class detail::csl_iterator : public detail::IteratorFacade<
csl_iterator<ValT, NodeT>,
ValT,
std::forward_iterator_tag> {
class detail::csl_iterator
: public detail::IteratorFacade<
csl_iterator<ValT, NodeT>,
ValT,
std::forward_iterator_tag> {
public:
typedef ValT value_type;
typedef value_type& reference;
Expand All @@ -685,8 +688,9 @@ class detail::csl_iterator : public detail::IteratorFacade<
: node_(other.node_) {}

size_t nodeSize() const {
return node_ == nullptr ? 0
: node_->height() * sizeof(NodeT*) + sizeof(*this);
return node_ == nullptr
? 0
: node_->height() * sizeof(NodeT*) + sizeof(*this);
}

bool good() const { return node_ != nullptr; }
Expand Down
7 changes: 4 additions & 3 deletions folly/ConstexprMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,10 @@ namespace detail {
template <typename U>
constexpr std::size_t constexpr_find_first_set_(
std::size_t s, std::size_t a, U const u) {
return s == 0 ? a
: constexpr_find_first_set_(
s / 2, a + s * bool((u >> a) % (U(1) << s) == U(0)), u);
return s == 0
? a
: constexpr_find_first_set_(
s / 2, a + s * bool((u >> a) % (U(1) << s) == U(0)), u);
}
} // namespace detail

Expand Down
10 changes: 6 additions & 4 deletions folly/Conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ class SignedValueHandler<T, true> {
}

ConversionCode overflow() {
return negative_ ? ConversionCode::NEGATIVE_OVERFLOW
: ConversionCode::POSITIVE_OVERFLOW;
return negative_
? ConversionCode::NEGATIVE_OVERFLOW
: ConversionCode::POSITIVE_OVERFLOW;
}

template <typename U>
Expand Down Expand Up @@ -658,8 +659,9 @@ Expected<Tgt, ConversionCode> str_to_integral(StringPiece* src) noexcept {

if (FOLLY_UNLIKELY(!tmp.hasValue())) {
return makeUnexpected(
tmp.error() == ConversionCode::POSITIVE_OVERFLOW ? sgn.overflow()
: tmp.error());
tmp.error() == ConversionCode::POSITIVE_OVERFLOW
? sgn.overflow()
: tmp.error());
}

auto res = sgn.finalize(tmp.value());
Expand Down
15 changes: 9 additions & 6 deletions folly/Conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,9 @@ typename std::enable_if<
sizeof(Src) >= 4>::type
toAppend(Src value, Tgt* result) {
char buffer[to_ascii_size_max_decimal<uint64_t>];
auto uvalue = value < 0 ? ~static_cast<uint64_t>(value) + 1
: static_cast<uint64_t>(value);
auto uvalue = value < 0
? ~static_cast<uint64_t>(value) + 1
: static_cast<uint64_t>(value);
if (value < 0) {
result->push_back('-');
}
Expand All @@ -575,8 +576,9 @@ typename std::enable_if<
sizeof(Src) < 16,
size_t>::type
estimateSpaceNeeded(Src value) {
auto uvalue = value < 0 ? ~static_cast<uint64_t>(value) + 1
: static_cast<uint64_t>(value);
auto uvalue = value < 0
? ~static_cast<uint64_t>(value) + 1
: static_cast<uint64_t>(value);
return size_t(value < 0) + to_ascii_size_decimal(uvalue);
}

Expand Down Expand Up @@ -1329,8 +1331,9 @@ FOLLY_NODISCARD inline typename std::enable_if< //
is_arithmetic_v<Tgt>,
Expected<StringPiece, ConversionCode>>::type
parseTo(StringPiece src, Tgt& out) {
return detail::convertTo<Tgt>(&src).then(
[&](Tgt res) { return void(out = res), src; });
return detail::convertTo<Tgt>(&src).then([&](Tgt res) {
return void(out = res), src;
});
}

/**
Expand Down
40 changes: 22 additions & 18 deletions folly/Expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,11 +727,12 @@ struct ExpectedHelper {
class E = ExpectedErrorType<This>,
class V = ExpectedValueType<This>,
class T = ExpectedHelper,
class RetValue = decltype(T::then_(
T::template return_<E>((std::declval<No>()(
std::declval<This>().error()))),
std::declval<AndFns>()...)
.value()),
class RetValue =
decltype(T::then_(
T::template return_<E>(
(std::declval<No>()(std::declval<This>().error()))),
std::declval<AndFns>()...)
.value()),
typename std::enable_if<!std::is_same<
std::remove_reference<RetValue>,
std::remove_reference<folly::Unit&&>>::value>::type* = nullptr,
Expand Down Expand Up @@ -763,11 +764,12 @@ struct ExpectedHelper {
class... AndFns,
class E = ExpectedErrorType<This>,
class T = ExpectedHelper,
class RetValue = decltype(T::then_(
T::template return_<E>((std::declval<No>()(
std::declval<This>().error()))),
std::declval<AndFns>()...)
.value()),
class RetValue =
decltype(T::then_(
T::template return_<E>(
(std::declval<No>()(std::declval<This>().error()))),
std::declval<AndFns>()...)
.value()),
typename std::enable_if<std::is_same<
std::remove_reference<RetValue>,
std::remove_reference<folly::Unit&&>>::value>::type* = nullptr,
Expand Down Expand Up @@ -1271,9 +1273,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
}

template <class... Fns FOLLY_REQUIRES_TRAILING(sizeof...(Fns) >= 1)>
auto then(Fns&&... fns) & -> decltype(expected_detail::ExpectedHelper::then_(
std::declval<Base&>(),
std::declval<Fns>()...)) {
auto
then(Fns&&... fns) & -> decltype(expected_detail::ExpectedHelper::then_(
std::declval<Base&>(), std::declval<Fns>()...)) {
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
}
Expand All @@ -1282,9 +1284,9 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
}

template <class... Fns FOLLY_REQUIRES_TRAILING(sizeof...(Fns) >= 1)>
auto then(Fns&&... fns) && -> decltype(expected_detail::ExpectedHelper::then_(
std::declval<Base&&>(),
std::declval<Fns>()...)) {
auto
then(Fns&&... fns) && -> decltype(expected_detail::ExpectedHelper::then_(
std::declval<Base&&>(), std::declval<Fns>()...)) {
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
}
Expand Down Expand Up @@ -1344,8 +1346,10 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
}

template <class Yes, class No = MakeBadExpectedAccess>
auto thenOrThrow(Yes&& yes, No&& no = No{}) & -> decltype(std::declval<Yes>()(
std::declval<Value&>())) {
auto thenOrThrow(
Yes&& yes,
No&& no =
No{}) & -> decltype(std::declval<Yes>()(std::declval<Value&>())) {
using Ret = decltype(std::declval<Yes>()(std::declval<Value&>()));
if (this->uninitializedByException()) {
throw_exception<BadExpectedAccess<void>>();
Expand Down
9 changes: 5 additions & 4 deletions folly/FBString.h
Original file line number Diff line number Diff line change
Expand Up @@ -1780,10 +1780,11 @@ class basic_fbstring {
template <typename E, class T, class A, class S>
FOLLY_NOINLINE typename basic_fbstring<E, T, A, S>::size_type
basic_fbstring<E, T, A, S>::traitsLength(const value_type* s) {
return s ? traits_type::length(s)
: (throw_exception<std::logic_error>(
"basic_fbstring: null pointer initializer not valid"),
0);
return s
? traits_type::length(s)
: (throw_exception<std::logic_error>(
"basic_fbstring: null pointer initializer not valid"),
0);
}

template <typename E, class T, class A, class S>
Expand Down
Loading

0 comments on commit abf77ba

Please sign in to comment.