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:
Markus Mäkelä 2018-04-19 15:23:14 +03:00
parent 050af8fb52
commit 92e0b944a9
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -377,6 +377,11 @@ public:
*/
virtual void finalize(GWBUF* buffer = NULL) = 0;
/**
* Reset the checksum to a zero state
*/
virtual void reset() = 0;
/**
* Get hexadecimal representation of the checksum
*
@ -411,6 +416,10 @@ public:
{
update(buffer);
SHA1_Final(&m_sum.front(), &m_ctx);
}
void reset()
{
SHA1_Init(&m_ctx);
}
@ -464,6 +473,11 @@ public:
{
update(buffer);
m_sum = m_ctx;
reset();
}
void reset()
{
m_ctx = crc32(0L, NULL, 0);
}