code: Use std::span where appropriate (#6658)

* code: Use std::span when possible

* code: Prefix memcpy and memcmp with std::
This commit is contained in:
GPUCode
2023-07-07 01:52:40 +03:00
committed by GitHub
parent 4ccd9f24fb
commit cf9bb90ae3
106 changed files with 362 additions and 329 deletions

View File

@ -4,6 +4,7 @@
#pragma once
#include <span>
#include <vector>
#include "common/common_types.h"
@ -14,24 +15,21 @@ 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 source_size the size in bytes 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<u8> CompressDataZSTD(const u8* source, std::size_t source_size,
s32 compression_level);
[[nodiscard]] std::vector<u8> CompressDataZSTD(std::span<const u8> source, 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_size the size in bytes of the uncompressed source memory region.
*
* @return the compressed data.
*/
[[nodiscard]] std::vector<u8> CompressDataZSTDDefault(const u8* source, std::size_t source_size);
[[nodiscard]] std::vector<u8> CompressDataZSTDDefault(std::span<const u8> source);
/**
* Decompresses a source memory region with Zstandard and returns the uncompressed data in a vector.
@ -40,6 +38,6 @@ namespace Common::Compression {
*
* @return the decompressed data.
*/
[[nodiscard]] std::vector<u8> DecompressDataZSTD(const std::vector<u8>& compressed);
[[nodiscard]] std::vector<u8> DecompressDataZSTD(std::span<const u8> compressed);
} // namespace Common::Compression