Skip to content

Commit

Permalink
SmallString: MSVC warning fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Sep 19, 2024
1 parent 0538b95 commit 96ece5d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/common/sha1_digest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void SHA1Digest::Reset()
count[0] = count[1] = 0;
}

std::string SHA1Digest::DigestToString(const std::span<u8, DIGEST_SIZE> digest)
std::string SHA1Digest::DigestToString(const std::span<const u8, DIGEST_SIZE> digest)
{
std::string ret;
ret.reserve(DIGEST_SIZE * 2);
Expand Down
4 changes: 2 additions & 2 deletions src/common/sha1_digest.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "types.h"

#include <array>
#include <string>
#include <span>
#include <string>

class SHA1Digest
{
Expand All @@ -24,7 +24,7 @@ class SHA1Digest
void Final(u8 digest[DIGEST_SIZE]);
void Reset();

static std::string DigestToString(const std::span<u8, DIGEST_SIZE> digest);
static std::string DigestToString(const std::span<const u8, DIGEST_SIZE> digest);

static std::array<u8, DIGEST_SIZE> GetDigest(const void* data, size_t len);
static std::array<u8, DIGEST_SIZE> GetDigest(std::span<const u8> data);
Expand Down
2 changes: 1 addition & 1 deletion src/common/small_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void SmallStringBase::append_hex(const void* data, size_t len, bool comma_separa
if (len == 0)
return;

static constexpr auto hex_char = [](char x) { return (x >= 0xA) ? ((x - 0xA) + 'a') : (x + '0'); };
static constexpr auto hex_char = [](char x) { return static_cast<char>((x >= 0xA) ? ((x - 0xA) + 'a') : (x + '0')); };
const u8* bytes = static_cast<const u8*>(data);

if (!comma_separate)
Expand Down
2 changes: 1 addition & 1 deletion src/common/string_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ std::optional<std::vector<u8>> StringUtil::DecodeHex(const std::string_view in)

std::string StringUtil::EncodeHex(const void* data, size_t length)
{
static constexpr auto hex_char = [](char x) { return (x >= 0xA) ? ((x - 0xA) + 'a') : (x + '0'); };
static constexpr auto hex_char = [](char x) { return static_cast<char>((x >= 0xA) ? ((x - 0xA) + 'a') : (x + '0')); };

const u8* bytes = static_cast<const u8*>(data);

Expand Down
4 changes: 1 addition & 3 deletions src/util/gpu_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,7 @@ bool GPUDevice::OpenPipelineCache(const std::string& path, Error* error)
const size_t cache_size = data->size();
const std::array<u8, SHA1Digest::DIGEST_SIZE> cache_hash = SHA1Digest::GetDigest(data->cspan());

INFO_LOG("Loading {} byte pipeline cache with hash {}", s_pipeline_cache_size,
SHA1Digest::DigestToString(s_pipeline_cache_hash));

INFO_LOG("Loading {} byte pipeline cache with hash {}", cache_size, SHA1Digest::DigestToString(cache_hash));
if (!ReadPipelineCache(std::move(data.value()), error))
return false;

Expand Down

0 comments on commit 96ece5d

Please sign in to comment.