mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-19 15:31:53 +00:00
Crypto/SHA1: Re-add memcpy avoiding optimization to BlockContext::Update.
This commit is contained in:
parent
0351fd56b1
commit
bb77d61967
1 changed files with 23 additions and 5 deletions
|
@ -72,20 +72,38 @@ protected:
|
|||
{
|
||||
m_msg_length += len;
|
||||
|
||||
size_t count_to_fill_block = m_block.size() - m_block_position;
|
||||
|
||||
while (len >= count_to_fill_block)
|
||||
// Block has some partial data. Copy msg into it.
|
||||
if (m_block_position != 0)
|
||||
{
|
||||
const size_t count_to_fill_block = m_block.size() - m_block_position;
|
||||
|
||||
// Not enough to fill block.
|
||||
if (len < count_to_fill_block)
|
||||
{
|
||||
std::copy_n(msg, len, m_block.data() + m_block_position);
|
||||
|
||||
m_block_position += len;
|
||||
return;
|
||||
}
|
||||
|
||||
std::copy_n(msg, count_to_fill_block, m_block.data() + m_block_position);
|
||||
ProcessBlock(m_block.data());
|
||||
|
||||
msg += count_to_fill_block;
|
||||
len -= count_to_fill_block;
|
||||
|
||||
m_block_position = 0;
|
||||
count_to_fill_block = m_block.size();
|
||||
}
|
||||
|
||||
// Our block is empty. We can process msg blocks directly, avoiding unnecessary copies.
|
||||
while (len >= m_block.size())
|
||||
{
|
||||
ProcessBlock(msg);
|
||||
|
||||
msg += m_block.size();
|
||||
len -= m_block.size();
|
||||
}
|
||||
|
||||
// Copy any remaining partial data into block.
|
||||
std::copy_n(msg, len, m_block.data() + m_block_position);
|
||||
m_block_position += len;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue