mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-22 14:55:03 +08:00
Merge pull request #1086 from mpilman/features/c++-compiler-errors
Fixed several minor code issues
This commit is contained in:
commit
ec32d3308b
@ -63,7 +63,7 @@ void parse( std::vector<RegionInfo>* regions, ValueRef const& v ) {
|
|||||||
RegionInfo info;
|
RegionInfo info;
|
||||||
json_spirit::mArray datacenters;
|
json_spirit::mArray datacenters;
|
||||||
dc.get("datacenters", datacenters);
|
dc.get("datacenters", datacenters);
|
||||||
bool nonSatelliteDatacenters = 0;
|
int nonSatelliteDatacenters = 0;
|
||||||
for (StatusObjectReader s : datacenters) {
|
for (StatusObjectReader s : datacenters) {
|
||||||
std::string idStr;
|
std::string idStr;
|
||||||
if (s.has("satellite") && s.last().get_int() == 1) {
|
if (s.has("satellite") && s.last().get_int() == 1) {
|
||||||
|
@ -1014,7 +1014,7 @@ namespace oldTLog {
|
|||||||
state Reference<LogData> logData;
|
state Reference<LogData> logData;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
bool foundCount = 0;
|
int foundCount = 0;
|
||||||
for(auto it : self->id_data) {
|
for(auto it : self->id_data) {
|
||||||
if(!it.second->stopped) {
|
if(!it.second->stopped) {
|
||||||
logData = it.second;
|
logData = it.second;
|
||||||
@ -1023,7 +1023,7 @@ namespace oldTLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(foundCount < 2);
|
ASSERT(foundCount < 2);
|
||||||
if(!foundCount) {
|
if(foundCount == 0) {
|
||||||
wait( self->newLogData.onTrigger() );
|
wait( self->newLogData.onTrigger() );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ static inline int commonPrefixLength(uint8_t const* ap, uint8_t const* bp, int c
|
|||||||
const int wordEnd = cl - sizeof(Word) + 1;
|
const int wordEnd = cl - sizeof(Word) + 1;
|
||||||
|
|
||||||
for(; i < wordEnd; i += sizeof(Word)) {
|
for(; i < wordEnd; i += sizeof(Word)) {
|
||||||
register Word a = *(Word *)ap;
|
Word a = *(Word *)ap;
|
||||||
register Word b = *(Word *)bp;
|
Word b = *(Word *)bp;
|
||||||
if(a != b) {
|
if(a != b) {
|
||||||
return i + ctzll(a ^ b) / 8;
|
return i + ctzll(a ^ b) / 8;
|
||||||
}
|
}
|
||||||
@ -238,14 +238,14 @@ struct PrefixTree {
|
|||||||
|
|
||||||
void init(const Node *n) {
|
void init(const Node *n) {
|
||||||
node = n;
|
node = n;
|
||||||
register union {
|
union {
|
||||||
const uint8_t *p8;
|
const uint8_t *p8;
|
||||||
const uint16_t *p16;
|
const uint16_t *p16;
|
||||||
};
|
};
|
||||||
p8 = (const uint8_t *)&n->flags + 1;
|
p8 = (const uint8_t *)&n->flags + 1;
|
||||||
|
|
||||||
register int flags = n->flags;
|
int flags = n->flags;
|
||||||
register bool large = flags & USE_LARGE_LENGTHS;
|
bool large = flags & USE_LARGE_LENGTHS;
|
||||||
|
|
||||||
prefixLen = large ? *p16++ : *p8++;
|
prefixLen = large ? *p16++ : *p8++;
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ struct PrefixTree {
|
|||||||
if(flags & HAS_VALUE)
|
if(flags & HAS_VALUE)
|
||||||
rightPos += (large ? *p16++ : *p8++);
|
rightPos += (large ? *p16++ : *p8++);
|
||||||
|
|
||||||
register int header = 2; // flags byte, first prefix len byte
|
int header = 2; // flags byte, first prefix len byte
|
||||||
if(large)
|
if(large)
|
||||||
++header; // second prefix len byte
|
++header; // second prefix len byte
|
||||||
if(flags & HAS_SPLIT)
|
if(flags & HAS_SPLIT)
|
||||||
|
@ -394,7 +394,7 @@ void sendResult( ReplyPromise<T>& reply, Optional<ErrorOr<T>> const& result ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ACTOR Future<Void> runWorkloadAsync( Database cx, WorkloadInterface workIface, TestWorkload *workload, double databasePingDelay ) {
|
ACTOR Future<Void> runWorkloadAsync( Database cx, WorkloadInterface workIface, TestWorkload *workload, double databasePingDelay ) {
|
||||||
state auto_ptr<TestWorkload> delw(workload);
|
state unique_ptr<TestWorkload> delw(workload);
|
||||||
state Optional<ErrorOr<Void>> setupResult;
|
state Optional<ErrorOr<Void>> setupResult;
|
||||||
state Optional<ErrorOr<Void>> startResult;
|
state Optional<ErrorOr<Void>> startResult;
|
||||||
state Optional<ErrorOr<bool>> checkResult;
|
state Optional<ErrorOr<bool>> checkResult;
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
T *object, ULONG flags = WT_EXECUTELONGFUNCTION)
|
T *object, ULONG flags = WT_EXECUTELONGFUNCTION)
|
||||||
{
|
{
|
||||||
typedef std::pair<void (T::*)(), T *> CallbackType;
|
typedef std::pair<void (T::*)(), T *> CallbackType;
|
||||||
std::auto_ptr<CallbackType> p(new CallbackType(function, object));
|
std::unique_ptr<CallbackType> p(new CallbackType(function, object));
|
||||||
|
|
||||||
if (::QueueUserWorkItem(ThreadProc<T>, p.get(), flags))
|
if (::QueueUserWorkItem(ThreadProc<T>, p.get(), flags))
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ private:
|
|||||||
{
|
{
|
||||||
typedef std::pair<void (T::*)(), T *> CallbackType;
|
typedef std::pair<void (T::*)(), T *> CallbackType;
|
||||||
|
|
||||||
std::auto_ptr<CallbackType> p(static_cast<CallbackType *>(context));
|
std::unique_ptr<CallbackType> p(static_cast<CallbackType *>(context));
|
||||||
|
|
||||||
(p->second->*p->first)();
|
(p->second->*p->first)();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -103,11 +103,13 @@ public:
|
|||||||
end++;
|
end++;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class U>
|
template<class... U>
|
||||||
void emplace_back(U && val) {
|
reference emplace_back(U&&... val) {
|
||||||
if (full()) grow();
|
if (full()) grow();
|
||||||
new (&arr[end&mask]) T(std::forward<U>(val));
|
new (&arr[end&mask]) T(std::forward<U>(val)...);
|
||||||
|
reference result = arr[end & mask];
|
||||||
end++;
|
end++;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pop_back() {
|
void pop_back() {
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <random>
|
||||||
#include "flow/UnitTest.h"
|
#include "flow/UnitTest.h"
|
||||||
|
|
||||||
template <class Node>
|
template <class Node>
|
||||||
@ -383,11 +384,12 @@ TEST_CASE("/flow/IndexedSet/comparison to std::set") {
|
|||||||
|
|
||||||
TEST_CASE("/flow/IndexedSet/all numbers") {
|
TEST_CASE("/flow/IndexedSet/all numbers") {
|
||||||
IndexedSet<int, int64_t> is;
|
IndexedSet<int, int64_t> is;
|
||||||
|
std::mt19937_64 urng(g_random->randomUInt32());
|
||||||
|
|
||||||
std::vector<int> allNumbers;
|
std::vector<int> allNumbers;
|
||||||
for (int i = 0; i<1000000; i++)
|
for (int i = 0; i<1000000; i++)
|
||||||
allNumbers.push_back(i);
|
allNumbers.push_back(i);
|
||||||
std::random_shuffle(allNumbers.begin(), allNumbers.end());
|
std::shuffle(allNumbers.begin(), allNumbers.end(), urng);
|
||||||
|
|
||||||
for (int i = 0; i<allNumbers.size(); i++)
|
for (int i = 0; i<allNumbers.size(); i++)
|
||||||
is.insert(allNumbers[i], allNumbers[i]);
|
is.insert(allNumbers[i], allNumbers[i]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user