mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-03 23:41:21 -07:00
Remove temporary std::string creation in some hex->bin calls
This commit is contained in:
parent
d1cf16364f
commit
81c5943453
@ -42,6 +42,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
|
#include <boost/utility/string_ref.hpp>
|
||||||
#include "misc_log_ex.h"
|
#include "misc_log_ex.h"
|
||||||
#include "storages/parserse_base_utils.h"
|
#include "storages/parserse_base_utils.h"
|
||||||
#include "hex.h"
|
#include "hex.h"
|
||||||
@ -69,7 +70,7 @@ namespace string_tools
|
|||||||
return to_hex::string(to_byte_span(to_span(src)));
|
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)
|
if (s.size() != res.size() * 2)
|
||||||
return false;
|
return false;
|
||||||
@ -90,7 +91,7 @@ namespace string_tools
|
|||||||
return true;
|
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)
|
if (s.size() & 1)
|
||||||
return false;
|
return false;
|
||||||
@ -303,7 +304,7 @@ POP_WARNINGS
|
|||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
template<class t_pod_type>
|
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");
|
static_assert(std::is_pod<t_pod_type>::value, "expected pod type");
|
||||||
if(sizeof(s)*2 != hex_str.size())
|
if(sizeof(s)*2 != hex_str.size())
|
||||||
@ -313,13 +314,13 @@ POP_WARNINGS
|
|||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
template<class t_pod_type>
|
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));
|
return hex_to_pod(hex_str, unwrap(s));
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
template<class t_pod_type>
|
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));
|
return hex_to_pod(hex_str, unwrap(s));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user