aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-11-26 15:49:17 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-12-08 02:00:37 +0000
commita13eb0a1a45b0ae255d97c2539c19e8bd701a1b8 (patch)
tree750e14b725c2dcccfef54f6b95c16783379003ce /contrib/epee
parentepee: avoid string allocation when parsing a pod from string (diff)
downloadmonero-a13eb0a1a45b0ae255d97c2539c19e8bd701a1b8.tar.xz
epee: speed up string matching a bit
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/storages/parserse_base_utils.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/epee/include/storages/parserse_base_utils.h b/contrib/epee/include/storages/parserse_base_utils.h
index 31495ae13..d73fbde3a 100644
--- a/contrib/epee/include/storages/parserse_base_utils.h
+++ b/contrib/epee/include/storages/parserse_base_utils.h
@@ -91,11 +91,15 @@ namespace misc_utils
*/
inline void match_string2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val)
{
- val.clear();
- val.reserve(std::distance(star_end_string, buf_end));
bool escape_mode = false;
std::string::const_iterator it = star_end_string;
++it;
+ std::string::const_iterator fi = it;
+ while (fi != buf_end && *fi != '\\' && *fi != '\"')
+ ++fi;
+ val.assign(it, fi);
+ val.reserve(std::distance(star_end_string, buf_end));
+ it = fi;
for(;it != buf_end;it++)
{
if(escape_mode/*prev_ch == '\\'*/)