mirror of https://gitee.com/bigwinds/arangodb
code cleanup
This commit is contained in:
parent
1a4ab1d0be
commit
fa45011ee7
|
@ -102,7 +102,7 @@ struct Entry {
|
||||||
// list of all items with the same key
|
// list of all items with the same key
|
||||||
IndexType prev; // index of the data preceding in the linked
|
IndexType prev; // index of the data preceding in the linked
|
||||||
// list of all items with the same key
|
// list of all items with the same key
|
||||||
uint64_t readHashCache() { return hashCache; }
|
uint64_t readHashCache() const { return hashCache; }
|
||||||
void writeHashCache(uint64_t v) { hashCache = v; }
|
void writeHashCache(uint64_t v) { hashCache = v; }
|
||||||
|
|
||||||
Entry() : hashCache(0), value(), next(INVALID_INDEX), prev(INVALID_INDEX) {}
|
Entry() : hashCache(0), value(), next(INVALID_INDEX), prev(INVALID_INDEX) {}
|
||||||
|
@ -118,7 +118,7 @@ struct Entry<Element, IndexType, false> {
|
||||||
// list of all items with the same key
|
// list of all items with the same key
|
||||||
IndexType prev; // index of the data preceding in the linked
|
IndexType prev; // index of the data preceding in the linked
|
||||||
// list of all items with the same key
|
// list of all items with the same key
|
||||||
uint64_t readHashCache() { return 0; }
|
uint64_t readHashCache() const { return 0; }
|
||||||
void writeHashCache(uint64_t v) { TRI_ASSERT(false); }
|
void writeHashCache(uint64_t v) { TRI_ASSERT(false); }
|
||||||
|
|
||||||
Entry() : value(), next(INVALID_INDEX), prev(INVALID_INDEX) {}
|
Entry() : value(), next(INVALID_INDEX), prev(INVALID_INDEX) {}
|
||||||
|
@ -223,6 +223,8 @@ class AssocMulti {
|
||||||
numberBuckets = nr;
|
numberBuckets = nr;
|
||||||
_bucketsMask = nr - 1;
|
_bucketsMask = nr - 1;
|
||||||
|
|
||||||
|
_buckets.reserve(numberBuckets);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (size_t j = 0; j < numberBuckets; j++) {
|
for (size_t j = 0; j < numberBuckets; j++) {
|
||||||
_buckets.emplace_back();
|
_buckets.emplace_back();
|
||||||
|
@ -540,13 +542,6 @@ class AssocMulti {
|
||||||
try {
|
try {
|
||||||
for (size_t i = 0; i < _buckets.size(); ++i) {
|
for (size_t i = 0; i < _buckets.size(); ++i) {
|
||||||
auto newBucket = new EntryType[static_cast<size_t>(_initialSize)]();
|
auto newBucket = new EntryType[static_cast<size_t>(_initialSize)]();
|
||||||
for (IndexType j = 0; j < _initialSize; ++j) {
|
|
||||||
newBucket[j].next = INVALID_INDEX;
|
|
||||||
newBucket[j].prev = INVALID_INDEX;
|
|
||||||
if (useHashCache) {
|
|
||||||
newBucket[j].writeHashCache(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// shouldn't fail as enough space was reserved above, but let's be paranoid
|
// shouldn't fail as enough space was reserved above, but let's be paranoid
|
||||||
empty.emplace_back(newBucket);
|
empty.emplace_back(newBucket);
|
||||||
|
|
|
@ -123,6 +123,8 @@ class AssocUnique {
|
||||||
numberBuckets = nr;
|
numberBuckets = nr;
|
||||||
_bucketsMask = nr - 1;
|
_bucketsMask = nr - 1;
|
||||||
|
|
||||||
|
_buckets.reserve(numberBuckets);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (size_t j = 0; j < numberBuckets; j++) {
|
for (size_t j = 0; j < numberBuckets; j++) {
|
||||||
_buckets.emplace_back();
|
_buckets.emplace_back();
|
||||||
|
@ -177,6 +179,12 @@ class AssocUnique {
|
||||||
if (b._nrAlloc >= targetSize && !allowShrink) {
|
if (b._nrAlloc >= targetSize && !allowShrink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (allowShrink &&
|
||||||
|
b._nrAlloc >= targetSize &&
|
||||||
|
b._nrAlloc < 1.25 * targetSize) {
|
||||||
|
// no need to shrink the bucket if it's not big enough
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::string const cb(_contextCallback());
|
std::string const cb(_contextCallback());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue