aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/string_tools.h
diff options
context:
space:
mode:
authorLee Clagett <code@leeclagett.com>2019-11-17 04:26:32 +0000
committerLee Clagett <code@leeclagett.com>2020-03-09 05:23:59 +0000
commit81c5943453fa7039912edadf51e68901a013b6a5 (patch)
treea2afcfd53402c977492013da01fdee705accee7e /contrib/epee/include/string_tools.h
parentMerge pull request #6388 (diff)
downloadmonero-81c5943453fa7039912edadf51e68901a013b6a5.tar.xz
Remove temporary std::string creation in some hex->bin calls
Diffstat (limited to '')
-rw-r--r--contrib/epee/include/string_tools.h11
1 files changed, 6 insertions, 5 deletions
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 <type_traits>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/predicate.hpp>
+#include <boost/utility/string_ref.hpp>
#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<const char> s, epee::span<char>& res)
+ inline bool parse_hexstr_to_binbuff(const boost::string_ref s, epee::span<char> 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<class t_pod_type>
- 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<t_pod_type>::value, "expected pod type");
if(sizeof(s)*2 != hex_str.size())
@@ -313,13 +314,13 @@ POP_WARNINGS
}
//----------------------------------------------------------------------------
template<class t_pod_type>
- bool hex_to_pod(const std::string& hex_str, tools::scrubbed<t_pod_type>& s)
+ bool hex_to_pod(const boost::string_ref hex_str, tools::scrubbed<t_pod_type>& s)
{
return hex_to_pod(hex_str, unwrap(s));
}
//----------------------------------------------------------------------------
template<class t_pod_type>
- bool hex_to_pod(const std::string& hex_str, epee::mlocked<t_pod_type>& s)
+ bool hex_to_pod(const boost::string_ref hex_str, epee::mlocked<t_pod_type>& s)
{
return hex_to_pod(hex_str, unwrap(s));
}