Core/HLE/HLE: Use std::string_view where applicable
Now that SymbolDB's querying functions accept std::string_view instances, we can alter the Patch/UnPatch HLE functions to follow suit.
This commit is contained in:
parent
936aa5dbaa
commit
a3046fe807
|
@ -80,11 +80,11 @@ constexpr std::array<SPatch, 1> OSBreakPoints{{
|
||||||
}};
|
}};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
void Patch(u32 addr, const char* hle_func_name)
|
void Patch(u32 addr, std::string_view func_name)
|
||||||
{
|
{
|
||||||
for (u32 i = 1; i < OSPatches.size(); ++i)
|
for (u32 i = 1; i < OSPatches.size(); ++i)
|
||||||
{
|
{
|
||||||
if (!strcmp(OSPatches[i].m_szPatchName, hle_func_name))
|
if (OSPatches[i].m_szPatchName == func_name)
|
||||||
{
|
{
|
||||||
s_original_instructions[addr] = i;
|
s_original_instructions[addr] = i;
|
||||||
PowerPC::ppcState.iCache.Invalidate(addr);
|
PowerPC::ppcState.iCache.Invalidate(addr);
|
||||||
|
@ -215,7 +215,7 @@ bool IsEnabled(HookFlag flag)
|
||||||
PowerPC::GetMode() == PowerPC::CoreMode::Interpreter;
|
PowerPC::GetMode() == PowerPC::CoreMode::Interpreter;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 UnPatch(const std::string& patch_name)
|
u32 UnPatch(std::string_view patch_name)
|
||||||
{
|
{
|
||||||
const auto patch = std::find_if(std::begin(OSPatches), std::end(OSPatches),
|
const auto patch = std::find_if(std::begin(OSPatches), std::end(OSPatches),
|
||||||
[&](const SPatch& p) { return patch_name == p.m_szPatchName; });
|
[&](const SPatch& p) { return patch_name == p.m_szPatchName; });
|
||||||
|
@ -258,7 +258,7 @@ u32 UnPatch(const std::string& patch_name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UnPatch(u32 addr, const std::string& name)
|
bool UnPatch(u32 addr, std::string_view name)
|
||||||
{
|
{
|
||||||
auto itr = s_original_instructions.find(addr);
|
auto itr = s_original_instructions.find(addr);
|
||||||
if (itr == s_original_instructions.end())
|
if (itr == s_original_instructions.end())
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string_view>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ void PatchFunctions();
|
||||||
void Clear();
|
void Clear();
|
||||||
void Reload();
|
void Reload();
|
||||||
|
|
||||||
void Patch(u32 pc, const char* func_name);
|
void Patch(u32 pc, std::string_view func_name);
|
||||||
u32 UnPatch(const std::string& patchName);
|
u32 UnPatch(std::string_view patch_name);
|
||||||
bool UnPatch(u32 addr, const std::string& name = {});
|
bool UnPatch(u32 addr, std::string_view name = {});
|
||||||
void Execute(u32 _CurrentPC, u32 _Instruction);
|
void Execute(u32 _CurrentPC, u32 _Instruction);
|
||||||
|
|
||||||
// Returns the HLE function index if the address is located in the function
|
// Returns the HLE function index if the address is located in the function
|
||||||
|
|
Loading…
Reference in New Issue