mirror of
https://gitee.com/openharmony/developtools_hiperf
synced 2024-11-23 07:29:42 +00:00
Avoid taking the remainder operation with a denominator of 0
Change-Id: Icbde475b4b4f20dcb7ab3722745e65017b0a9f8e Signed-off-by: leiguangyu <leiguangyu@huawei.com>
This commit is contained in:
parent
3784c605bf
commit
bd57644f4c
@ -128,7 +128,7 @@ private:
|
||||
uint32_t totalNodes_ = 0;
|
||||
// current available node count, include index 0
|
||||
uint32_t availableNodes_ = 0;
|
||||
uint32_t hashModulus_ = 0;
|
||||
uint32_t hashModulus_ = 1;
|
||||
// 0 for reserved, start from 1
|
||||
uint32_t availableIndex_ = 1;
|
||||
// for de-conflict
|
||||
|
@ -31,7 +31,7 @@ bool UniqueStackTable::Init()
|
||||
}
|
||||
|
||||
availableNodes_ = totalNodes_;
|
||||
hashModulus_ = availableNodes_ >= 1 ? availableNodes_ - 1 : 0;
|
||||
hashModulus_ = availableNodes_ > 1 ? availableNodes_ - 1 : 1;
|
||||
hashStep_ = (totalNodes_ / (deconflictTimes_ * HASH_STEP_BASE_MULTIPLE + HASH_STEP_BASE_NUM));
|
||||
tableBuf_ = std::make_unique<uint8_t[]>(tableSize_);
|
||||
|
||||
@ -71,7 +71,7 @@ bool UniqueStackTable::Resize()
|
||||
availableIndex_ += availableNodes_;
|
||||
totalNodes_ = ((newtableSize / sizeof(Node)) >> 1) << 1; // make it even.
|
||||
availableNodes_ = totalNodes_ - oldNumNodes;
|
||||
hashModulus_ = availableNodes_ >= 1 ? availableNodes_ - 1 : 0;
|
||||
hashModulus_ = availableNodes_ > 1 ? availableNodes_ - 1 : 1;
|
||||
hashStep_ = availableNodes_ / (deconflictTimes_ * HASH_STEP_BASE_MULTIPLE + HASH_STEP_BASE_NUM);
|
||||
HLOGI("After resize, totalNodes_: %u, availableNodes_: %u, availableIndex_: %u hashStep_: %" PRIu64 "",
|
||||
totalNodes_, availableNodes_, availableIndex_, hashStep_);
|
||||
|
Loading…
Reference in New Issue
Block a user