constant_pool: Convert hashtype from tuple to pair

This commit is contained in:
Wunkolo 2021-12-23 18:16:55 -08:00 committed by merry
parent befc22a61e
commit e57bb0569a
2 changed files with 5 additions and 5 deletions

View file

@ -21,7 +21,7 @@ ConstantPool::ConstantPool(BlockOfCode& code, size_t size)
} }
Xbyak::Address ConstantPool::GetConstant(const Xbyak::AddressFrame& frame, u64 lower, u64 upper) { Xbyak::Address ConstantPool::GetConstant(const Xbyak::AddressFrame& frame, u64 lower, u64 upper) {
const auto constant = std::make_tuple(lower, upper); const auto constant = std::make_pair(lower, upper);
auto iter = constant_info.find(constant); auto iter = constant_info.find(constant);
if (iter == constant_info.end()) { if (iter == constant_info.end()) {
ASSERT(static_cast<size_t>(current_pool_ptr - pool_begin) < pool_size); ASSERT(static_cast<size_t>(current_pool_ptr - pool_begin) < pool_size);

View file

@ -6,8 +6,8 @@
#pragma once #pragma once
#include <bit> #include <bit>
#include <tuple>
#include <unordered_map> #include <unordered_map>
#include <utility>
#include <xbyak/xbyak.h> #include <xbyak/xbyak.h>
@ -31,12 +31,12 @@ private:
static constexpr size_t align_size = 16; // bytes static constexpr size_t align_size = 16; // bytes
struct ConstantHash { struct ConstantHash {
std::size_t operator()(const std::tuple<u64, u64>& constant) const { std::size_t operator()(const std::pair<u64, u64>& constant) const noexcept {
return std::get<0>(constant) ^ std::rotl<u64>(std::get<1>(constant), 1); return constant.first ^ std::rotl<u64>(constant.second, 1);
} }
}; };
std::unordered_map<std::tuple<u64, u64>, void*, ConstantHash> constant_info; std::unordered_map<std::pair<u64, u64>, void*, ConstantHash> constant_info;
BlockOfCode& code; BlockOfCode& code;
size_t pool_size; size_t pool_size;