diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-08-19 22:40:30 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-10-24 08:34:25 +0000 |
commit | 07c6280909f8d6bb4d4d8e2399b56a0ce02393c6 (patch) | |
tree | df76f6f2b011ca011c98e8d897dcbc14fd450131 | |
parent | Merge pull request #4697 (diff) | |
download | monero-07c6280909f8d6bb4d4d8e2399b56a0ce02393c6.tar.xz |
epee: some minor speedup in parsing
-rw-r--r-- | contrib/epee/include/storages/parserse_base_utils.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/contrib/epee/include/storages/parserse_base_utils.h b/contrib/epee/include/storages/parserse_base_utils.h index 8c6c1a64d..31495ae13 100644 --- a/contrib/epee/include/storages/parserse_base_utils.h +++ b/contrib/epee/include/storages/parserse_base_utils.h @@ -39,12 +39,14 @@ namespace misc_utils inline std::string transform_to_escape_sequence(const std::string& src) { 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; std::string res; 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) { |