uint32_t
CPack::decompressWord(const Pattern* pattern)
{
- std::array<uint8_t, 4> data;
-
// Search for matching entry
std::vector<std::array<uint8_t, 4>>::iterator entry_it =
dictionary.begin();
// Decompress the match. If the decompressed value must be added to
// the dictionary, do it
- if (pattern->decompress(*entry_it, data)) {
+ const std::array<uint8_t, 4> data = pattern->decompress(*entry_it);
+ if (pattern->shouldAllocate()) {
dictionary[numEntries++] = data;
}
* its data.
*
* @param dict_bytes The bytes in the corresponding matching entry.
- * @param data The decompressed pattern.
- * @return Whether entry should be added to dictionary or not.
+ * @return The decompressed pattern.
*/
- virtual bool decompress(const std::array<uint8_t, 4> dict_bytes,
- std::array<uint8_t, 4>& data) const = 0;
+ virtual std::array<uint8_t, 4> decompress(
+ const std::array<uint8_t, 4> dict_bytes) const = 0;
};
class CPack::PatternZZZZ : public Pattern
(bytes[0] == 0);
}
- bool decompress(const std::array<uint8_t, 4> dict_bytes,
- std::array<uint8_t, 4>& data) const override
+ std::array<uint8_t, 4>
+ decompress(const std::array<uint8_t, 4> dict_bytes) const override
{
- data = {0, 0, 0, 0};
- return false;
+ return {0, 0, 0, 0};
}
};
return true;
}
- bool decompress(const std::array<uint8_t, 4> dict_bytes,
- std::array<uint8_t, 4>& data) const override
+ std::array<uint8_t, 4>
+ decompress(const std::array<uint8_t, 4> dict_bytes) const override
{
- data = bytes;
- return true;
+ return bytes;
}
};
return (bytes == dict_bytes) && (match_location >= 0);
}
- bool decompress(const std::array<uint8_t, 4> dict_bytes,
- std::array<uint8_t, 4>& data) const override
+ std::array<uint8_t, 4>
+ decompress(const std::array<uint8_t, 4> dict_bytes) const override
{
- data = dict_bytes;
- return true;
+ return dict_bytes;
}
};
}
- bool decompress(const std::array<uint8_t, 4> dict_bytes,
- std::array<uint8_t, 4>& data) const override
+ std::array<uint8_t, 4>
+ decompress(const std::array<uint8_t, 4> dict_bytes) const override
{
- data = {byte0, byte1, dict_bytes[2], dict_bytes[3]};
- return true;
+ return {byte0, byte1, dict_bytes[2], dict_bytes[3]};
}
};
(bytes[0] != 0);
}
- bool decompress(const std::array<uint8_t, 4> dict_bytes,
- std::array<uint8_t, 4>& data) const override
+ std::array<uint8_t, 4>
+ decompress(const std::array<uint8_t, 4> dict_bytes) const override
{
- data = {byte, 0, 0, 0};
- return false;
+ return {byte, 0, 0, 0};
}
};
(match_location >= 0);
}
- bool decompress(const std::array<uint8_t, 4> dict_bytes,
- std::array<uint8_t, 4>& data) const override
+ std::array<uint8_t, 4>
+ decompress(const std::array<uint8_t, 4> dict_bytes) const override
{
- data = {byte, dict_bytes[1], dict_bytes[2], dict_bytes[3]};
- return true;
+ return {byte, dict_bytes[1], dict_bytes[2], dict_bytes[3]};
}
};