replace with std::log2
This commit is contained in:
parent
18bd4b5a34
commit
49903900de
2 changed files with 8 additions and 29 deletions
|
@ -5,23 +5,10 @@
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
#include "core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.h"
|
#include "core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
s32 Log2(s32 value) {
|
|
||||||
ASSERT(value > 0);
|
|
||||||
ASSERT(Common::IsPowerOfTwo(value));
|
|
||||||
|
|
||||||
s32 log = 0;
|
|
||||||
while ((value >>= 1) > 0) {
|
|
||||||
++log;
|
|
||||||
}
|
|
||||||
return log;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 layer_count,
|
Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 layer_count,
|
||||||
size_t htbs, void* hash_buf, size_t hash_buf_size) {
|
size_t htbs, void* hash_buf, size_t hash_buf_size) {
|
||||||
// Validate preconditions.
|
// Validate preconditions.
|
||||||
|
@ -31,7 +18,8 @@ Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 lay
|
||||||
|
|
||||||
// Set size tracking members.
|
// Set size tracking members.
|
||||||
m_hash_target_block_size = static_cast<s32>(htbs);
|
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.
|
// Get the base storage size.
|
||||||
m_base_storage_size = base_storages[2]->GetSize();
|
m_base_storage_size = base_storages[2]->GetSize();
|
||||||
|
|
|
@ -5,19 +5,9 @@
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
#include "core/file_sys/fssystem/fssystem_hierarchical_sha3_storage.h"
|
#include "core/file_sys/fssystem/fssystem_hierarchical_sha3_storage.h"
|
||||||
|
|
||||||
namespace FileSys {
|
#include <cmath>
|
||||||
|
|
||||||
namespace {
|
namespace FileSys {
|
||||||
s32 Log2(s32 value) {
|
|
||||||
ASSERT(value > 0);
|
|
||||||
ASSERT(Common::IsPowerOfTwo(value));
|
|
||||||
s32 log = 0;
|
|
||||||
while ((value >>= 1) > 0) {
|
|
||||||
++log;
|
|
||||||
}
|
|
||||||
return log;
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
Result HierarchicalSha3Storage::Initialize(VirtualFile* base_storages, s32 layer_count, size_t htbs,
|
Result HierarchicalSha3Storage::Initialize(VirtualFile* base_storages, s32 layer_count, size_t htbs,
|
||||||
void* hash_buf, size_t hash_buf_size) {
|
void* hash_buf, size_t hash_buf_size) {
|
||||||
|
@ -26,7 +16,8 @@ Result HierarchicalSha3Storage::Initialize(VirtualFile* base_storages, s32 layer
|
||||||
ASSERT(hash_buf != nullptr);
|
ASSERT(hash_buf != nullptr);
|
||||||
|
|
||||||
m_hash_target_block_size = static_cast<s32>(htbs);
|
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();
|
m_base_storage_size = base_storages[2]->GetSize();
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue