mirror of
https://github.com/monero-project/monero.git
synced 2024-12-26 12:59:26 -05:00
epee: some speedup in parsing
This commit is contained in:
parent
29dea03091
commit
76affd941b
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
{
|
{
|
||||||
namespace misc_utils
|
namespace misc_utils
|
||||||
@ -36,8 +38,12 @@ namespace misc_utils
|
|||||||
{
|
{
|
||||||
inline std::string transform_to_escape_sequence(const std::string& src)
|
inline std::string transform_to_escape_sequence(const std::string& src)
|
||||||
{
|
{
|
||||||
//std::stringstream res;
|
static const char escaped[] = "\b\f\n\r\t\v\"\\/";
|
||||||
|
if (std::find_first_of(src.begin(), src.end(), escaped, escaped + sizeof(escaped)) == src.end())
|
||||||
|
return src;
|
||||||
|
|
||||||
std::string res;
|
std::string res;
|
||||||
|
res.reserve(2 * src.size());
|
||||||
for(std::string::const_iterator it = src.begin(); it!=src.end(); ++it)
|
for(std::string::const_iterator it = src.begin(); it!=src.end(); ++it)
|
||||||
{
|
{
|
||||||
switch(*it)
|
switch(*it)
|
||||||
@ -84,6 +90,7 @@ namespace misc_utils
|
|||||||
inline void match_string2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val)
|
inline void match_string2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val)
|
||||||
{
|
{
|
||||||
val.clear();
|
val.clear();
|
||||||
|
val.reserve(std::distance(star_end_string, buf_end));
|
||||||
bool escape_mode = false;
|
bool escape_mode = false;
|
||||||
std::string::const_iterator it = star_end_string;
|
std::string::const_iterator it = star_end_string;
|
||||||
++it;
|
++it;
|
||||||
|
Loading…
Reference in New Issue
Block a user