From c39ea2e3c9f4addb9aee35fe57812b2818e0cde9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 15 Sep 2018 14:57:07 -0400 Subject: [PATCH] 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. --- src/backend/x64/perf_map.cpp | 4 ++-- src/backend/x64/perf_map.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/x64/perf_map.cpp b/src/backend/x64/perf_map.cpp index beaf8b83..fee125de 100644 --- a/src/backend/x64/perf_map.cpp +++ b/src/backend/x64/perf_map.cpp @@ -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() {} diff --git a/src/backend/x64/perf_map.h b/src/backend/x64/perf_map.h index 80f933fb..dbdd499d 100644 --- a/src/backend/x64/perf_map.h +++ b/src/backend/x64/perf_map.h @@ -8,17 +8,18 @@ #include #include +#include #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 -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(start), end, friendly_name); }