common: Make use of [[nodiscard]] where applicable

Now that clang-format makes [[nodiscard]] attributes format sensibly, we
can apply them to several functions within the common library to allow
the compiler to complain about any misuses of the functions.
This commit is contained in:
Lioncash 2020-08-14 09:38:45 -04:00
parent 2b601e8636
commit df72480395
34 changed files with 343 additions and 358 deletions

View file

@ -18,7 +18,7 @@ namespace Common::Compression {
*
* @return the compressed data.
*/
std::vector<u8> CompressDataLZ4(std::span<const u8> source);
[[nodiscard]] std::vector<u8> CompressDataLZ4(std::span<const u8> source);
/**
* Utilizes the LZ4 subalgorithm LZ4HC with the specified compression level. Higher compression
@ -31,7 +31,7 @@ std::vector<u8> CompressDataLZ4(std::span<const u8> source);
*
* @return the compressed data.
*/
std::vector<u8> CompressDataLZ4HC(std::span<const u8> source, s32 compression_level);
[[nodiscard]] std::vector<u8> CompressDataLZ4HC(std::span<const u8> source, s32 compression_level);
/**
* Utilizes the LZ4 subalgorithm LZ4HC with the highest possible compression level.
@ -40,7 +40,7 @@ std::vector<u8> CompressDataLZ4HC(std::span<const u8> source, s32 compression_le
*
* @return the compressed data.
*/
std::vector<u8> CompressDataLZ4HCMax(std::span<const u8> source);
[[nodiscard]] std::vector<u8> CompressDataLZ4HCMax(std::span<const u8> source);
/**
* Decompresses a source memory region with LZ4 and returns the uncompressed data in a vector.
@ -50,6 +50,7 @@ std::vector<u8> CompressDataLZ4HCMax(std::span<const u8> source);
*
* @return the decompressed data.
*/
std::vector<u8> DecompressDataLZ4(const std::vector<u8>& compressed, std::size_t uncompressed_size);
[[nodiscard]] std::vector<u8> DecompressDataLZ4(const std::vector<u8>& compressed,
std::size_t uncompressed_size);
} // namespace Common::Compression