From 663696fe7219c43612ecde4439a8fa9d9e672f8c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 15 Aug 2019 23:39:43 -0400 Subject: [PATCH] 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. --- include/LZ77/LZLookupTable.hpp | 5 +++-- src/LZ77/LZLookupTable.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/LZ77/LZLookupTable.hpp b/include/LZ77/LZLookupTable.hpp index 61bfb9e..bd66516 100644 --- a/include/LZ77/LZLookupTable.hpp +++ b/include/LZ77/LZLookupTable.hpp @@ -9,7 +9,8 @@ struct LZLengthOffset { atUint32 length; // The number of bytes compressed 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 { @@ -17,7 +18,7 @@ public: LZLookupTable(); LZLookupTable(atInt32 minimumMatch, atInt32 slidingWindow = 4096, atInt32 lookAheadWindow = 18); ~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); private: diff --git a/src/LZ77/LZLookupTable.cpp b/src/LZ77/LZLookupTable.cpp index 0809c84..e7b7ba6 100644 --- a/src/LZ77/LZLookupTable.cpp +++ b/src/LZ77/LZLookupTable.cpp @@ -36,7 +36,7 @@ void LZLookupTable::setLookAheadWindow(atInt32 lookAheadWindow) { 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}; // Returns negative 1 for search failures since the current position is passed the size to be compressed