mirror of
https://github.com/momo5502/emulator.git
synced 2026-02-01 19:15:23 +01:00
Apply suggested changes
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include "string.hpp"
|
||||||
|
|
||||||
namespace utils
|
namespace utils
|
||||||
{
|
{
|
||||||
@@ -26,9 +27,9 @@ namespace utils
|
|||||||
{
|
{
|
||||||
size_t hash = 0;
|
size_t hash = 0;
|
||||||
constexpr std::hash<int> hasher{};
|
constexpr std::hash<int> hasher{};
|
||||||
for (unsigned char c : str)
|
for (const char c : str)
|
||||||
{
|
{
|
||||||
hash ^= hasher(std::tolower(c)) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
|
hash ^= hasher(string::char_to_lower(c)) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
@@ -40,8 +41,9 @@ namespace utils
|
|||||||
|
|
||||||
bool operator()(const std::string_view lhs, const std::string_view rhs) const
|
bool operator()(const std::string_view lhs, const std::string_view rhs) const
|
||||||
{
|
{
|
||||||
return std::ranges::equal(
|
return std::ranges::equal(lhs, rhs, [](const char c1, const char c2) {
|
||||||
lhs, rhs, [](unsigned char c1, unsigned char c2) { return std::tolower(c1) == std::tolower(c2); });
|
return string::char_to_lower(c1) == string::char_to_lower(c2);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ std::optional<registry_key> registry_manager::get_key(const utils::path_key& key
|
|||||||
return {std::move(reg_key)};
|
return {std::move(reg_key)};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<registry_value> registry_manager::get_value(const registry_key& key, const std::string& name)
|
std::optional<registry_value> registry_manager::get_value(const registry_key& key, std::string_view name)
|
||||||
{
|
{
|
||||||
const auto iterator = this->hives_.find(key.hive);
|
const auto iterator = this->hives_.find(key.hive);
|
||||||
if (iterator == this->hives_.end())
|
if (iterator == this->hives_.end())
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class registry_manager
|
|||||||
registry_manager& operator=(const registry_manager&) = delete;
|
registry_manager& operator=(const registry_manager&) = delete;
|
||||||
|
|
||||||
std::optional<registry_key> get_key(const utils::path_key& key);
|
std::optional<registry_key> get_key(const utils::path_key& key);
|
||||||
std::optional<registry_value> get_value(const registry_key& key, const std::string& name);
|
std::optional<registry_value> get_value(const registry_key& key, std::string_view name);
|
||||||
std::optional<registry_value> get_value(const registry_key& key, size_t index);
|
std::optional<registry_value> get_value(const registry_key& key, size_t index);
|
||||||
|
|
||||||
std::optional<std::string_view> get_sub_key_name(const registry_key& key, size_t index);
|
std::optional<std::string_view> get_sub_key_name(const registry_key& key, size_t index);
|
||||||
|
|||||||
Reference in New Issue
Block a user