Skip to content

Commit ff8749e

Browse files
generatedunixname2413856222380011meta-codesync[bot]
authored andcommitted
fbcode/folly/test
Reviewed By: ak7 Differential Revision: D93095639 fbshipit-source-id: e9f139a0f1c7b0ff1771cdc1866069e0855cb8c5
1 parent 7bfda85 commit ff8749e

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

third-party/folly/src/folly/test/ConcurrentSkipListTest.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <folly/Memory.h>
2929
#include <folly/Random.h>
3030
#include <folly/String.h>
31-
#include <folly/container/Foreach.h>
3231
#include <folly/memory/Arena.h>
3332
#include <folly/portability/GFlags.h>
3433
#include <folly/portability/GTest.h>
@@ -111,8 +110,8 @@ static void randomRemoval(
111110

112111
static void sumAllValues(SkipListAccessor skipList, int64_t* sum) {
113112
*sum = 0;
114-
FOR_EACH (it, skipList) {
115-
*sum += *it;
113+
for (const auto& value : skipList) {
114+
*sum += value;
116115
}
117116
VLOG(20) << "sum = " << sum;
118117
}
@@ -121,21 +120,21 @@ static void concurrentSkip(
121120
const vector<ValueType>* values, SkipListAccessor skipList) {
122121
int64_t sum = 0;
123122
SkipListAccessor::Skipper skipper(skipList);
124-
FOR_EACH (it, *values) {
125-
if (skipper.to(*it)) {
126-
sum += *it;
123+
for (const auto& value : *values) {
124+
if (skipper.to(value)) {
125+
sum += value;
127126
}
128127
}
129128
VLOG(20) << "sum = " << sum;
130129
}
131130

132131
bool verifyEqual(SkipListAccessor skipList, const SetType& verifier) {
133132
EXPECT_EQ(verifier.size(), skipList.size());
134-
FOR_EACH (it, verifier) {
135-
CHECK(skipList.contains(*it)) << *it;
136-
SkipListType::const_iterator iter = skipList.find(*it);
133+
for (const auto& value : verifier) {
134+
CHECK(skipList.contains(value)) << value;
135+
SkipListType::const_iterator iter = skipList.find(value);
137136
CHECK(iter != skipList.end());
138-
EXPECT_EQ(*iter, *it);
137+
EXPECT_EQ(*iter, value);
139138
}
140139
EXPECT_TRUE(std::equal(verifier.begin(), verifier.end(), skipList.begin()));
141140
return true;
@@ -322,8 +321,8 @@ TEST(ConcurrentSkipList, ConcurrentAdd) {
322321
}
323322

324323
SetType all;
325-
FOR_EACH (s, verifiers) {
326-
all.insert(s->begin(), s->end());
324+
for (auto& verifier : verifiers) {
325+
all.insert(verifier.begin(), verifier.end());
327326
}
328327
verifyEqual(skipList, all);
329328
}
@@ -345,13 +344,13 @@ void testConcurrentRemoval(int numThreads, int maxValue) {
345344
LOG(WARNING) << "Caught " << exceptionStr(e) << ": could only create "
346345
<< threads.size() << " threads out of " << numThreads;
347346
}
348-
FOR_EACH (t, threads) {
349-
(*t).join();
347+
for (auto& thread : threads) {
348+
thread.join();
350349
}
351350

352351
SetType all;
353-
FOR_EACH (s, verifiers) {
354-
all.insert(s->begin(), s->end());
352+
for (auto& verifier : verifiers) {
353+
all.insert(verifier.begin(), verifier.end());
355354
}
356355

357356
CHECK_EQ(maxValue, all.size() + skipList.size());
@@ -406,8 +405,8 @@ static void testConcurrentAccess(
406405
}
407406
}
408407

409-
FOR_EACH (t, threads) {
410-
(*t).join();
408+
for (auto& thread : threads) {
409+
thread.join();
411410
}
412411
// just run through it, no need to verify the correctness.
413412
}

0 commit comments

Comments
 (0)