perf_map: Use std::string_view instead of std::string for PerfMapRegister()

We can just use a non-owning view into a string in this case instead of
potentially allocating a std::string instance.
This commit is contained in:
Lioncash 2018-09-15 14:57:07 -04:00 committed by MerryMage
parent 12243692f5
commit c39ea2e3c9
2 changed files with 5 additions and 4 deletions

View file

@ -45,7 +45,7 @@ void OpenFile() {
} // anonymous namespace
namespace detail {
void PerfMapRegister(const void* start, const void* end, const std::string& friendly_name) {
void PerfMapRegister(const void* start, const void* end, std::string_view friendly_name) {
std::lock_guard guard{mutex};
if (!file) {
@ -79,7 +79,7 @@ void PerfMapClear() {
namespace Dynarmic::BackendX64 {
namespace detail {
void PerfMapRegister(const void*, const void*, const std::string&) {}
void PerfMapRegister(const void*, const void*, std::string_view) {}
} // namespace detail
void PerfMapClear() {}

View file

@ -8,17 +8,18 @@
#include <cstddef>
#include <string>
#include <string_view>
#include "common/cast_util.h"
namespace Dynarmic::BackendX64 {
namespace detail {
void PerfMapRegister(const void* start, const void* end, const std::string& friendly_name);
void PerfMapRegister(const void* start, const void* end, std::string_view friendly_name);
} // namespace detail
template<typename T>
void PerfMapRegister(T start, const void* end, const std::string& friendly_name) {
void PerfMapRegister(T start, const void* end, std::string_view friendly_name) {
detail::PerfMapRegister(Common::BitCast<const void*>(start), end, friendly_name);
}