Use std::string_view in cpu code

This commit is contained in:
Megamouse
2026-06-14 06:28:05 +02:00
parent 54b8b5399b
commit e5cdae8c5a
9 changed files with 16 additions and 16 deletions
+2 -2
View File
@@ -525,7 +525,7 @@ class jit_compiler final
atomic_t<usz> m_disk_space = umax;
public:
jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, u32 flags = 0, std::function<u64(const std::string&)> symbols_cement = {}) noexcept;
jit_compiler(const std::unordered_map<std::string, u64>& _link, std::string_view _cpu, u32 flags = 0, std::function<u64(const std::string&)> symbols_cement = {}) noexcept;
jit_compiler& operator=(thread_state) noexcept;
~jit_compiler() noexcept;
@@ -571,7 +571,7 @@ public:
u64 get(const std::string& name);
// Get CPU info
static std::string cpu(const std::string& _cpu);
static std::string cpu(std::string_view _cpu);
// Get system triple (PPU)
static std::string triple1();
+3 -3
View File
@@ -551,9 +551,9 @@ public:
}
};
std::string jit_compiler::cpu(const std::string& _cpu)
std::string jit_compiler::cpu(std::string_view _cpu)
{
std::string m_cpu = _cpu;
std::string m_cpu = std::string(_cpu);
if (m_cpu.empty())
{
@@ -681,7 +681,7 @@ bool jit_compiler::add_sub_disk_space(ssz space)
}).second;
}
jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, u32 flags, std::function<u64(const std::string&)> symbols_cement) noexcept
jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, std::string_view _cpu, u32 flags, std::function<u64(const std::string&)> symbols_cement) noexcept
: m_context(new llvm::LLVMContext)
, m_cpu(cpu(_cpu))
{
+2 -2
View File
@@ -14,7 +14,7 @@ namespace utils
// Printing utilities
template <typename T>
concept Logger = requires (T& t, const std::string& msg)
concept Logger = requires (T& t, std::string_view msg)
{
{ t.print(msg) };
};
@@ -28,7 +28,7 @@ namespace utils
: log(chan)
{}
void print(const std::string& s)
void print(std::string_view s)
{
log.error("%s", s);
}