Add stepsCount parameter to private Arc4Gen::Step(), avoiding unnecessary function calls when possible.
This commit is contained in:
@@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
for (uint64_t cnt = 0; cnt < bytesCount; ++cnt)
|
for (uint64_t cnt = 0; cnt < bytesCount; ++cnt)
|
||||||
{
|
{
|
||||||
Step();
|
Step(1);
|
||||||
*out++ = Lookup_[static_cast<uint8_t>(Lookup_[I_] + Lookup_[J_])];
|
*out++ = Lookup_[static_cast<uint8_t>(Lookup_[I_] + Lookup_[J_])];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,11 +44,7 @@ public:
|
|||||||
void Drop(uint64_t bytesCount)
|
void Drop(uint64_t bytesCount)
|
||||||
{
|
{
|
||||||
EnsureInitialized();
|
EnsureInitialized();
|
||||||
|
Step(bytesCount);
|
||||||
for (uint64_t cnt = 0; cnt < bytesCount; ++cnt)
|
|
||||||
{
|
|
||||||
Step();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -98,13 +94,16 @@ private:
|
|||||||
IsInitialized_ = true;
|
IsInitialized_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Step()
|
void Step(uint64_t stepsCount)
|
||||||
|
{
|
||||||
|
for (uint64_t k = 0; k < stepsCount; ++k)
|
||||||
{
|
{
|
||||||
I_ = I_ + 1;
|
I_ = I_ + 1;
|
||||||
J_ = J_ + Lookup_[I_];
|
J_ = J_ + Lookup_[I_];
|
||||||
|
|
||||||
std::swap(Lookup_[I_], Lookup_[J_]);
|
std::swap(Lookup_[I_], Lookup_[J_]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Chaos::Cipher::Arc4
|
} // namespace Chaos::Cipher::Arc4
|
||||||
|
|||||||
Reference in New Issue
Block a user