diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-01-06 20:36:46 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-01-06 20:36:46 +0200 |
commit | ad1eb3338c071fc3774a0c2599228c8aa953e087 (patch) | |
tree | 058efcebcff467ed3370cf86a98b355ebc1b749c /contrib/epee/include/storages | |
parent | Merge pull request #4934 (diff) | |
parent | epee: speed up string matching a bit (diff) | |
download | monero-ad1eb3338c071fc3774a0c2599228c8aa953e087.tar.xz |
Merge pull request #4938
a13eb0a1 epee: speed up string matching a bit (moneromooo-monero)
3a3858dc epee: avoid string allocation when parsing a pod from string (moneromooo-monero)
Diffstat (limited to 'contrib/epee/include/storages')
-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 == '\\'*/) |