From 81c5943453fa7039912edadf51e68901a013b6a5 Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Sun, 17 Nov 2019 04:26:32 +0000 Subject: Remove temporary std::string creation in some hex->bin calls --- contrib/epee/include/string_tools.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'contrib') diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h index 319c0121b..f9581a4e4 100644 --- a/contrib/epee/include/string_tools.h +++ b/contrib/epee/include/string_tools.h @@ -42,6 +42,7 @@ #include #include #include +#include #include "misc_log_ex.h" #include "storages/parserse_base_utils.h" #include "hex.h" @@ -69,7 +70,7 @@ namespace string_tools return to_hex::string(to_byte_span(to_span(src))); } //---------------------------------------------------------------------------- - inline bool parse_hexstr_to_binbuff(const epee::span s, epee::span& res) + inline bool parse_hexstr_to_binbuff(const boost::string_ref s, epee::span res) { if (s.size() != res.size() * 2) return false; @@ -90,7 +91,7 @@ namespace string_tools return true; } //---------------------------------------------------------------------------- - inline bool parse_hexstr_to_binbuff(const std::string& s, std::string& res) + inline bool parse_hexstr_to_binbuff(const boost::string_ref s, std::string& res) { if (s.size() & 1) return false; @@ -303,7 +304,7 @@ POP_WARNINGS } //---------------------------------------------------------------------------- template - bool hex_to_pod(const std::string& hex_str, t_pod_type& s) + bool hex_to_pod(const boost::string_ref hex_str, t_pod_type& s) { static_assert(std::is_pod::value, "expected pod type"); if(sizeof(s)*2 != hex_str.size()) @@ -313,13 +314,13 @@ POP_WARNINGS } //---------------------------------------------------------------------------- template - bool hex_to_pod(const std::string& hex_str, tools::scrubbed& s) + bool hex_to_pod(const boost::string_ref hex_str, tools::scrubbed& s) { return hex_to_pod(hex_str, unwrap(s)); } //---------------------------------------------------------------------------- template - bool hex_to_pod(const std::string& hex_str, epee::mlocked& s) + bool hex_to_pod(const boost::string_ref hex_str, epee::mlocked& s) { return hex_to_pod(hex_str, unwrap(s)); } -- cgit v1.2.3