From df7248039553b3ebd338380c3ef0428b0e046e79 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 14 Aug 2020 09:38:45 -0400 Subject: 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. --- src/common/zstd_compression.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common/zstd_compression.h') diff --git a/src/common/zstd_compression.h b/src/common/zstd_compression.h index b5edf19e7..4bacf8355 100644 --- a/src/common/zstd_compression.h +++ b/src/common/zstd_compression.h @@ -19,7 +19,7 @@ namespace Common::Compression { * * @return the compressed data. */ -std::vector CompressDataZSTD(std::span source, s32 compression_level); +[[nodiscard]] std::vector CompressDataZSTD(std::span source, s32 compression_level); /** * Compresses a source memory region with Zstandard with the default compression level and returns @@ -29,7 +29,7 @@ std::vector CompressDataZSTD(std::span source, s32 compression_lev * * @return the compressed data. */ -std::vector CompressDataZSTDDefault(std::span source); +[[nodiscard]] std::vector CompressDataZSTDDefault(std::span source); /** * Decompresses a source memory region with Zstandard and returns the uncompressed data in a vector. @@ -38,6 +38,6 @@ std::vector CompressDataZSTDDefault(std::span source); * * @return the decompressed data. */ -std::vector DecompressDataZSTD(const std::vector& compressed); +[[nodiscard]] std::vector DecompressDataZSTD(const std::vector& compressed); } // namespace Common::Compression \ No newline at end of file -- cgit v1.2.3 From 1ee060ca0dfae7d0a1c830c7495f3125acf0ec7f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 15 Aug 2020 05:25:28 -0400 Subject: common/compression: Roll back std::span changes Seems like all compilers don't support std::span yet. --- src/common/zstd_compression.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/common/zstd_compression.h') diff --git a/src/common/zstd_compression.h b/src/common/zstd_compression.h index 4bacf8355..c26a30ab9 100644 --- a/src/common/zstd_compression.h +++ b/src/common/zstd_compression.h @@ -4,7 +4,6 @@ #pragma once -#include #include #include "common/common_types.h" @@ -14,22 +13,25 @@ namespace Common::Compression { /** * Compresses a source memory region with Zstandard and returns the compressed data in a vector. * - * @param source the uncompressed source memory region. - * @param compression_level the used compression level. Should be between 1 and 22. + * @param source The uncompressed source memory region. + * @param source_size The size of the uncompressed source memory region. + * @param compression_level The used compression level. Should be between 1 and 22. * * @return the compressed data. */ -[[nodiscard]] std::vector CompressDataZSTD(std::span source, s32 compression_level); +[[nodiscard]] std::vector CompressDataZSTD(const u8* source, std::size_t source_size, + s32 compression_level); /** * Compresses a source memory region with Zstandard with the default compression level and returns * the compressed data in a vector. * - * @param source the uncompressed source memory region. + * @param source The uncompressed source memory region. + * @param source_size The size of the uncompressed source memory region. * * @return the compressed data. */ -[[nodiscard]] std::vector CompressDataZSTDDefault(std::span source); +[[nodiscard]] std::vector CompressDataZSTDDefault(const u8* source, std::size_t source_size); /** * Decompresses a source memory region with Zstandard and returns the uncompressed data in a vector. -- cgit v1.2.3