Is there any way to improve the performance of this function? As I have to call it ~10-100M times for 1 calculation it's slowing down my program and most time has been lost in this line:
myHand_param.FinalHandVector.push_back((1 << static_cast<int>(std::ceil((i - 3.0) / 4.0))));
I know that the vector capacity should never exceed 5 but I don't know how to skip the boundary checking, tried to work with int* instead of vector but it didn't help as well.
void CalculateKickers(Hand& myHand_param, int kickersNeeded)
{
int countKickers{ 0 };
for(int i = bits-1; i > 0 ; i--)
{
if (static_cast<std::bitset<bits>>(myHand_param.handMask)[i] == 1)
{
if (static_cast<std::bitset<1>>((static_cast<std::bitset<bits>>(myHand_param.FinalHandUsedCardFacesMask) >> i).to_ullong())== 0)
{
++countKickers;
myHand_param.FinalHandVector.push_back((1 << static_cast<int>(std::ceil((i - 3.0) / 4.0))));
if (countKickers == kickersNeeded)
{
i = 0;
}
}
}
}
}