From 936aa5dbaa123f748a8e4c0297372f01616b8302 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Sun, 16 Jun 2019 01:09:58 -0400
Subject: [PATCH 1/2] Common/SymbolDB: Use std::string_view where applicable

These strings are only used for comparison against other strings, so a
string view can be used here.
---
 Source/Core/Common/SymbolDB.cpp | 4 ++--
 Source/Core/Common/SymbolDB.h   | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Source/Core/Common/SymbolDB.cpp b/Source/Core/Common/SymbolDB.cpp
index c24faaa8c9..2df5fa0d78 100644
--- a/Source/Core/Common/SymbolDB.cpp
+++ b/Source/Core/Common/SymbolDB.cpp
@@ -63,7 +63,7 @@ void SymbolDB::Index()
   }
 }
 
-Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
+Symbol* SymbolDB::GetSymbolFromName(std::string_view name)
 {
   for (auto& func : m_functions)
   {
@@ -74,7 +74,7 @@ Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
   return nullptr;
 }
 
-std::vector<Symbol*> SymbolDB::GetSymbolsFromName(const std::string& name)
+std::vector<Symbol*> SymbolDB::GetSymbolsFromName(std::string_view name)
 {
   std::vector<Symbol*> symbols;
 
diff --git a/Source/Core/Common/SymbolDB.h b/Source/Core/Common/SymbolDB.h
index 8d389b5a92..502d410fff 100644
--- a/Source/Core/Common/SymbolDB.h
+++ b/Source/Core/Common/SymbolDB.h
@@ -10,6 +10,7 @@
 #include <map>
 #include <set>
 #include <string>
+#include <string_view>
 #include <utility>
 #include <vector>
 
@@ -71,8 +72,8 @@ public:
   virtual Symbol* AddFunction(u32 start_addr) { return nullptr; }
   void AddCompleteSymbol(const Symbol& symbol);
 
-  Symbol* GetSymbolFromName(const std::string& name);
-  std::vector<Symbol*> GetSymbolsFromName(const std::string& name);
+  Symbol* GetSymbolFromName(std::string_view name);
+  std::vector<Symbol*> GetSymbolsFromName(std::string_view name);
   Symbol* GetSymbolFromHash(u32 hash);
   std::vector<Symbol*> GetSymbolsFromHash(u32 hash);
 

From a3046fe8071e4d70b9cec93f59fa4b9c559355d2 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Sun, 16 Jun 2019 01:14:14 -0400
Subject: [PATCH 2/2] 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.
---
 Source/Core/Core/HLE/HLE.cpp | 8 ++++----
 Source/Core/Core/HLE/HLE.h   | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp
index d1206b756b..e9fc504528 100644
--- a/Source/Core/Core/HLE/HLE.cpp
+++ b/Source/Core/Core/HLE/HLE.cpp
@@ -80,11 +80,11 @@ constexpr std::array<SPatch, 1> OSBreakPoints{{
 }};
 // 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)
   {
-    if (!strcmp(OSPatches[i].m_szPatchName, hle_func_name))
+    if (OSPatches[i].m_szPatchName == func_name)
     {
       s_original_instructions[addr] = i;
       PowerPC::ppcState.iCache.Invalidate(addr);
@@ -215,7 +215,7 @@ bool IsEnabled(HookFlag flag)
          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 SPatch& p) { return patch_name == p.m_szPatchName; });
@@ -258,7 +258,7 @@ u32 UnPatch(const std::string& patch_name)
   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);
   if (itr == s_original_instructions.end())
diff --git a/Source/Core/Core/HLE/HLE.h b/Source/Core/Core/HLE/HLE.h
index 9f851e0396..6e07b832a7 100644
--- a/Source/Core/Core/HLE/HLE.h
+++ b/Source/Core/Core/HLE/HLE.h
@@ -4,7 +4,7 @@
 
 #pragma once
 
-#include <string>
+#include <string_view>
 
 #include "Common/CommonTypes.h"
 
@@ -29,9 +29,9 @@ void PatchFunctions();
 void Clear();
 void Reload();
 
-void Patch(u32 pc, const char* func_name);
-u32 UnPatch(const std::string& patchName);
-bool UnPatch(u32 addr, const std::string& name = {});
+void Patch(u32 pc, std::string_view func_name);
+u32 UnPatch(std::string_view patch_name);
+bool UnPatch(u32 addr, std::string_view name = {});
 void Execute(u32 _CurrentPC, u32 _Instruction);
 
 // Returns the HLE function index if the address is located in the function