LZLookupTable: Make member functions const where applicable

While we're at it, we can convert compare_equal into an operator==
operator!= pair, and make the curPos argument to search() const as well.
This commit is contained in:
Lioncash 2019-08-15 23:39:43 -04:00
parent 48ae0d32fe
commit 663696fe72
2 changed files with 4 additions and 3 deletions

View File

@ -9,7 +9,8 @@
struct LZLengthOffset { struct LZLengthOffset {
atUint32 length; // The number of bytes compressed atUint32 length; // The number of bytes compressed
atUint16 offset; // How far back in sliding window where bytes that match the lookAheadBuffer is located atUint16 offset; // How far back in sliding window where bytes that match the lookAheadBuffer is located
bool compare_equal(const LZLengthOffset& lo_pair) { return length == lo_pair.length && offset == lo_pair.offset; } bool operator==(const LZLengthOffset& lo_pair) const { return length == lo_pair.length && offset == lo_pair.offset; }
bool operator!=(const LZLengthOffset& lo_pair) const { return !operator==(lo_pair); }
}; };
class LZLookupTable { class LZLookupTable {
@ -17,7 +18,7 @@ public:
LZLookupTable(); LZLookupTable();
LZLookupTable(atInt32 minimumMatch, atInt32 slidingWindow = 4096, atInt32 lookAheadWindow = 18); LZLookupTable(atInt32 minimumMatch, atInt32 slidingWindow = 4096, atInt32 lookAheadWindow = 18);
~LZLookupTable(); ~LZLookupTable();
LZLengthOffset search(atUint8* curPos, const atUint8* dataBegin, const atUint8* dataEnd); LZLengthOffset search(const atUint8* curPos, const atUint8* dataBegin, const atUint8* dataEnd);
void setLookAheadWindow(atInt32 lookAheadWindow); void setLookAheadWindow(atInt32 lookAheadWindow);
private: private:

View File

@ -36,7 +36,7 @@ void LZLookupTable::setLookAheadWindow(atInt32 lookAheadWindow) {
m_lookAheadWindow = 18; m_lookAheadWindow = 18;
} }
LZLengthOffset LZLookupTable::search(atUint8* curPos, const atUint8* dataBegin, const atUint8* dataEnd) { LZLengthOffset LZLookupTable::search(const atUint8* curPos, const atUint8* dataBegin, const atUint8* dataEnd) {
LZLengthOffset loPair = {0, 0}; LZLengthOffset loPair = {0, 0};
// Returns negative 1 for search failures since the current position is passed the size to be compressed // Returns negative 1 for search failures since the current position is passed the size to be compressed