Add stepsCount parameter to private Arc4Gen::Step(), avoiding unnecessary function calls when possible.

This commit is contained in:
hashlag
2025-09-04 22:48:49 +03:00
parent 177b6ab1e8
commit e309ed5c28

View File

@@ -36,7 +36,7 @@ public:
for (uint64_t cnt = 0; cnt < bytesCount; ++cnt)
{
Step();
Step(1);
*out++ = Lookup_[static_cast<uint8_t>(Lookup_[I_] + Lookup_[J_])];
}
}
@@ -44,11 +44,7 @@ public:
void Drop(uint64_t bytesCount)
{
EnsureInitialized();
for (uint64_t cnt = 0; cnt < bytesCount; ++cnt)
{
Step();
}
Step(bytesCount);
}
private:
@@ -98,13 +94,16 @@ private:
IsInitialized_ = true;
}
void Step()
void Step(uint64_t stepsCount)
{
for (uint64_t k = 0; k < stepsCount; ++k)
{
I_ = I_ + 1;
J_ = J_ + Lookup_[I_];
std::swap(Lookup_[I_], Lookup_[J_]);
}
}
};
} // namespace Chaos::Cipher::Arc4