Merge pull request #4709
07c62809
epee: some minor speedup in parsing (moneromooo-monero)
This commit is contained in:
commit
7ceeaec2e5
|
@ -39,12 +39,14 @@ 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)
|
||||||
{
|
{
|
||||||
static const char escaped[] = "\b\f\n\r\t\v\"\\/";
|
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())
|
std::string::const_iterator it = std::find_first_of(src.begin(), src.end(), escaped, escaped + sizeof(escaped));
|
||||||
|
if (it == src.end())
|
||||||
return src;
|
return src;
|
||||||
|
|
||||||
std::string res;
|
std::string res;
|
||||||
res.reserve(2 * src.size());
|
res.reserve(2 * src.size());
|
||||||
for(std::string::const_iterator it = src.begin(); it!=src.end(); ++it)
|
res.assign(src.begin(), it);
|
||||||
|
for(; it!=src.end(); ++it)
|
||||||
{
|
{
|
||||||
switch(*it)
|
switch(*it)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue