From 0fbcb9b49997e6994011da3b0d82667bfca6dd20 Mon Sep 17 00:00:00 2001 From: Redbeanw44602 Date: Sat, 1 Mar 2025 23:42:20 +0800 Subject: [PATCH] fix: correct use of string types. --- src/data_format/bound_symbol_list.cpp | 8 ++++---- src/data_format/bound_symbol_list.h | 2 +- src/frontend_action/dump_symbol.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/data_format/bound_symbol_list.cpp b/src/data_format/bound_symbol_list.cpp index eda061a..b312989 100644 --- a/src/data_format/bound_symbol_list.cpp +++ b/src/data_format/bound_symbol_list.cpp @@ -39,11 +39,11 @@ void BoundSymbolList::write(const fs::path& path) const { } void BoundSymbolList::record( - std::string_view symbol, - rva_t rva, - bool is_function + const std::string& symbol, + rva_t rva, + bool is_function ) { - m_entities.emplace(BoundSymbol{std::string(symbol), rva, is_function}); + m_entities.emplace(BoundSymbol{symbol, rva, is_function}); } } // namespace di::data_format diff --git a/src/data_format/bound_symbol_list.h b/src/data_format/bound_symbol_list.h index 7194270..fbb7f7e 100644 --- a/src/data_format/bound_symbol_list.h +++ b/src/data_format/bound_symbol_list.h @@ -12,7 +12,7 @@ public: void read(const fs::path& path) override; void write(const fs::path& path) const override; - void record(std::string_view symbol, rva_t rva, bool is_function); + void record(const std::string& symbol, rva_t rva, bool is_function); constexpr void for_each(const for_each_callback_t& callback) const { for (const auto& entity : m_entities) callback(entity); diff --git a/src/frontend_action/dump_symbol.cpp b/src/frontend_action/dump_symbol.cpp index 8b2c76f..9618aca 100644 --- a/src/frontend_action/dump_symbol.cpp +++ b/src/frontend_action/dump_symbol.cpp @@ -52,7 +52,7 @@ public: // Do not mangle template deduction guides. if (isa(decl)) return true; - std::string mangled_name = m_namegen.getName(decl); + auto mangled_name = m_namegen.getName(decl); if (!mangled_name.empty()) { if (config_record_decl_name) { mangled_name = std::format(