Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Jan 6, 2025
1 parent 40b4cd8 commit 0636638
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
29 changes: 13 additions & 16 deletions include/momo/details/HashBucketOpen2N2.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,25 @@ namespace internal
typedef BucketParamsOpen<MemManager> Params;

private:
template<size_t count, bool useHashCodePartGetter>
struct HashData;
typedef typename UIntSelector<useHashCodePartGetter ? 1 : 2>::UInt ShortHash;

template<size_t count>
struct HashData<count, false>
template<size_t codeCount = maxCount, bool hasCodeProbes = useHashCodePartGetter>
struct HashData
{
union
{
uint16_t shortHashes[count];
uint8_t hashProbes[count];
};
ShortHash shortHashes[codeCount];
uint8_t hashProbes[codeCount];
};

template<size_t count>
struct HashData<count, true>
template<size_t codeCount>
struct HashData<codeCount, false>
{
uint8_t shortHashes[count];
uint8_t hashProbes[count];
union
{
ShortHash shortHashes[codeCount];
uint8_t hashProbes[codeCount];
};
};

typedef typename UIntSelector<useHashCodePartGetter ? 1 : 2>::UInt ShortHash;

static const size_t hashCodeShift = sizeof(size_t) * 8 - sizeof(ShortHash) * 8 + 1;
static const ShortHash emptyShortHash = ShortHash{1} << (sizeof(ShortHash) * 8 - 1);
static const uint8_t emptyHashProbe = 255;
Expand Down Expand Up @@ -257,7 +254,7 @@ namespace internal

private:
uint8_t mState[2];
HashData<maxCount, useHashCodePartGetter> mHashData;
HashData<> mHashData;
ObjectBuffer<Item, ItemTraits::alignment, maxCount> mItems;
};
}
Expand Down
11 changes: 4 additions & 7 deletions include/momo/details/TreeNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,17 @@ namespace internal
private:
typedef BoolConstant<isContinuous> IsContinuous;

template<size_t capacity, bool hasIndexes>
struct Counter;

template<size_t capacity>
struct Counter<capacity, false>
template<size_t capacity = maxCapacity, size_t indexCount = isContinuous ? 0 : capacity>
struct Counter
{
uint8_t count;
uint8_t indexes[indexCount];
};

template<size_t capacity>
struct Counter<capacity, true>
struct Counter<capacity, 0>
{
uint8_t count;
uint8_t indexes[capacity];
};

typedef internal::MemManagerPtr<MemManager> MemManagerPtr;
Expand Down

0 comments on commit 0636638

Please sign in to comment.