diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-11-26 15:49:17 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-12-08 02:00:37 +0000 |
commit | a13eb0a1a45b0ae255d97c2539c19e8bd701a1b8 (patch) | |
tree | 750e14b725c2dcccfef54f6b95c16783379003ce /contrib/epee | |
parent | epee: avoid string allocation when parsing a pod from string (diff) | |
download | monero-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.h | 8 |
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 == '\\'*/) |