diff options
| author | Lioncash <mai.iam2048@gmail.com> | 2023-01-24 14:25:49 -0500 |
|---|---|---|
| committer | Lioncash <mai.iam2048@gmail.com> | 2023-01-24 14:58:20 -0500 |
| commit | e5b91f00b0688d5cba6870da6d6ad3300097b07f (patch) | |
| tree | 09ec8ac31ff935d63aa9c06004802156ac96ebf5 /Source/Core/Common/Debug/CodeTrace.cpp | |
| parent | ba6ee9d7ba9730e5b2165ff0ee18cbc23762b129 (diff) | |
Common: Replace StringBeginsWith/StringEndsWith with std equivalents
Obsoletes these functions in favor of the standard member functions
added in C++20.
Diffstat (limited to 'Source/Core/Common/Debug/CodeTrace.cpp')
| -rw-r--r-- | Source/Core/Common/Debug/CodeTrace.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Source/Core/Common/Debug/CodeTrace.cpp b/Source/Core/Common/Debug/CodeTrace.cpp index 3eea7a72fc..d1cb913356 100644 --- a/Source/Core/Common/Debug/CodeTrace.cpp +++ b/Source/Core/Common/Debug/CodeTrace.cpp @@ -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; |
