MXS-1810: Create reset method for Checksum
Resetting checksum calculations avoids some unnecessary calculations when the result is not needed.
This commit is contained in:
@ -377,6 +377,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void finalize(GWBUF* buffer = NULL) = 0;
|
virtual void finalize(GWBUF* buffer = NULL) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the checksum to a zero state
|
||||||
|
*/
|
||||||
|
virtual void reset() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get hexadecimal representation of the checksum
|
* Get hexadecimal representation of the checksum
|
||||||
*
|
*
|
||||||
@ -411,6 +416,10 @@ public:
|
|||||||
{
|
{
|
||||||
update(buffer);
|
update(buffer);
|
||||||
SHA1_Final(&m_sum.front(), &m_ctx);
|
SHA1_Final(&m_sum.front(), &m_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
SHA1_Init(&m_ctx);
|
SHA1_Init(&m_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,6 +473,11 @@ public:
|
|||||||
{
|
{
|
||||||
update(buffer);
|
update(buffer);
|
||||||
m_sum = m_ctx;
|
m_sum = m_ctx;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
m_ctx = crc32(0L, NULL, 0);
|
m_ctx = crc32(0L, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user