Browse Source

replace with std::log2

pull/298/head
Maufeat 6 months ago
committed by crueter
parent
commit
49903900de
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 20
      src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp
  2. 17
      src/core/file_sys/fssystem/fssystem_hierarchical_sha3_storage.cpp

20
src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp

@ -5,22 +5,9 @@
#include "common/scope_exit.h"
#include "core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.h"
namespace FileSys {
namespace {
#include <cmath>
s32 Log2(s32 value) {
ASSERT(value > 0);
ASSERT(Common::IsPowerOfTwo(value));
s32 log = 0;
while ((value >>= 1) > 0) {
++log;
}
return log;
}
} // namespace
namespace FileSys {
Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 layer_count,
size_t htbs, void* hash_buf, size_t hash_buf_size) {
@ -31,7 +18,8 @@ Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 lay
// Set size tracking members.
m_hash_target_block_size = static_cast<s32>(htbs);
m_log_size_ratio = Log2(m_hash_target_block_size / HashSize);
m_log_size_ratio =
static_cast<s32>(std::log2(static_cast<double>(m_hash_target_block_size) / HashSize));
// Get the base storage size.
m_base_storage_size = base_storages[2]->GetSize();

17
src/core/file_sys/fssystem/fssystem_hierarchical_sha3_storage.cpp

@ -5,19 +5,9 @@
#include "common/scope_exit.h"
#include "core/file_sys/fssystem/fssystem_hierarchical_sha3_storage.h"
namespace FileSys {
#include <cmath>
namespace {
s32 Log2(s32 value) {
ASSERT(value > 0);
ASSERT(Common::IsPowerOfTwo(value));
s32 log = 0;
while ((value >>= 1) > 0) {
++log;
}
return log;
}
} // namespace
namespace FileSys {
Result HierarchicalSha3Storage::Initialize(VirtualFile* base_storages, s32 layer_count, size_t htbs,
void* hash_buf, size_t hash_buf_size) {
@ -26,7 +16,8 @@ Result HierarchicalSha3Storage::Initialize(VirtualFile* base_storages, s32 layer
ASSERT(hash_buf != nullptr);
m_hash_target_block_size = static_cast<s32>(htbs);
m_log_size_ratio = Log2(m_hash_target_block_size / HashSize);
m_log_size_ratio =
static_cast<s32>(std::log2(static_cast<double>(m_hash_target_block_size) / HashSize));
m_base_storage_size = base_storages[2]->GetSize();
{

Loading…
Cancel
Save