Common: Replace StringBeginsWith/StringEndsWith with std equivalents

Obsoletes these functions in favor of the standard member functions
added in C++20.
This commit is contained in:
Lioncash
2023-01-24 14:25:49 -05:00
parent ba6ee9d7ba
commit e5b91f00b0
21 changed files with 57 additions and 97 deletions

View File

@ -3,11 +3,11 @@
#include "Common/Debug/CodeTrace.h"
#include <algorithm>
#include <chrono>
#include <regex>
#include "Common/Event.h"
#include "Common/StringUtil.h"
#include "Core/Debugger/PPCDebugInterface.h"
#include "Core/HW/CPU.h"
#include "Core/PowerPC/PowerPC.h"
@ -16,9 +16,8 @@ namespace
{
bool IsInstructionLoadStore(std::string_view ins)
{
return (StringBeginsWith(ins, "l") && !StringBeginsWith(ins, "li")) ||
StringBeginsWith(ins, "st") || StringBeginsWith(ins, "psq_l") ||
StringBeginsWith(ins, "psq_s");
return (ins.starts_with('l') && !ins.starts_with("li")) || ins.starts_with("st") ||
ins.starts_with("psq_l") || ins.starts_with("psq_s");
}
u32 GetMemoryTargetSize(std::string_view instr)
@ -95,7 +94,7 @@ InstructionAttributes CodeTrace::GetInstructionAttributes(const TraceOutput& ins
tmp_attributes.memory_target = instruction.memory_target;
tmp_attributes.memory_target_size = GetMemoryTargetSize(instr);
if (StringBeginsWith(instr, "st") || StringBeginsWith(instr, "psq_s"))
if (instr.starts_with("st") || instr.starts_with("psq_s"))
tmp_attributes.is_store = true;
else
tmp_attributes.is_load = true;
@ -263,9 +262,8 @@ HitType CodeTrace::TraceLogic(const TraceOutput& current_instr, bool first_hit)
// Checks if the intstruction is a type that needs special handling.
const auto CompareInstruction = [](std::string_view instruction, const auto& type_compare) {
return std::any_of(
type_compare.begin(), type_compare.end(),
[&instruction](std::string_view s) { return StringBeginsWith(instruction, s); });
return std::any_of(type_compare.begin(), type_compare.end(),
[&instruction](std::string_view s) { return instruction.starts_with(s); });
};
// Exclusions from updating tracking logic. mt operations are too complex and specialized.
@ -280,12 +278,12 @@ HitType CodeTrace::TraceLogic(const TraceOutput& current_instr, bool first_hit)
static const std::array<std::string_view, 2> mover{"mr", "fmr"};
// Link register for when r0 gets overwritten
if (StringBeginsWith(instr.instruction, "mflr") && match_reg0)
if (instr.instruction.starts_with("mflr") && match_reg0)
{
m_reg_autotrack.erase(reg_itr);
return HitType::OVERWRITE;
}
else if (StringBeginsWith(instr.instruction, "mtlr") && match_reg0)
if (instr.instruction.starts_with("mtlr") && match_reg0)
{
// LR is not something tracked
return HitType::MOVED;