From 60d10d2813c964dc58b0e3d9f64a175e60271ad9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Jun 2019 12:22:00 -0400 Subject: [PATCH] Core/DSP/DSPTables: Make FindOpInfoByName/FindExtOpInfoByName use std::string_view These functions only ever compare against another string, so these can have their parameters turned into std::string_view to make them more flexible. --- Source/Core/Core/DSP/DSPTables.cpp | 6 +++--- Source/Core/Core/DSP/DSPTables.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/DSP/DSPTables.cpp b/Source/Core/Core/DSP/DSPTables.cpp index 8672082c84..30deea113f 100644 --- a/Source/Core/Core/DSP/DSPTables.cpp +++ b/Source/Core/Core/DSP/DSPTables.cpp @@ -511,7 +511,7 @@ std::array s_op_table; std::array s_ext_op_table; template -auto FindByName(const std::string& name, const std::array& data) +auto FindByName(std::string_view name, const std::array& data) { return std::find_if(data.cbegin(), data.cend(), [&name](const auto& info) { return name == info.name; }); @@ -527,7 +527,7 @@ const DSPOPCTemplate* FindOpInfoByOpcode(UDSPInstruction opcode) return &*iter; } -const DSPOPCTemplate* FindOpInfoByName(const std::string& name) +const DSPOPCTemplate* FindOpInfoByName(std::string_view name) { const auto iter = FindByName(name, s_opcodes); if (iter == s_opcodes.cend()) @@ -545,7 +545,7 @@ const DSPOPCTemplate* FindExtOpInfoByOpcode(UDSPInstruction opcode) return &*iter; } -const DSPOPCTemplate* FindExtOpInfoByName(const std::string& name) +const DSPOPCTemplate* FindExtOpInfoByName(std::string_view name) { const auto iter = FindByName(name, s_opcodes_ext); if (iter == s_opcodes_ext.cend()) diff --git a/Source/Core/Core/DSP/DSPTables.h b/Source/Core/Core/DSP/DSPTables.h index b3d0689685..40004da3fc 100644 --- a/Source/Core/Core/DSP/DSPTables.h +++ b/Source/Core/Core/DSP/DSPTables.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "Core/DSP/DSPCommon.h" @@ -111,10 +111,10 @@ void ZeroWriteBackLogPreserveAcc(u8 acc); // Used by the assembler and disassembler for info retrieval. const DSPOPCTemplate* FindOpInfoByOpcode(UDSPInstruction opcode); -const DSPOPCTemplate* FindOpInfoByName(const std::string& name); +const DSPOPCTemplate* FindOpInfoByName(std::string_view name); const DSPOPCTemplate* FindExtOpInfoByOpcode(UDSPInstruction opcode); -const DSPOPCTemplate* FindExtOpInfoByName(const std::string& name); +const DSPOPCTemplate* FindExtOpInfoByName(std::string_view name); // Used by the interpreter and JIT for instruction emulation const DSPOPCTemplate* GetOpTemplate(UDSPInstruction inst);