aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-08-16 18:15:47 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-08-19 15:29:01 +0000
commit76affd941b1b32dccecbe4001415a43a2edeffa3 (patch)
tree2a8effc27cce1c807483f721cc527eb506d05555 /contrib
parentepee: resize vectors where possible in serialization (diff)
downloadmonero-76affd941b1b32dccecbe4001415a43a2edeffa3.tar.xz
epee: some speedup in parsing
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/include/storages/parserse_base_utils.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/contrib/epee/include/storages/parserse_base_utils.h b/contrib/epee/include/storages/parserse_base_utils.h
index c809392f4..8c6c1a64d 100644
--- a/contrib/epee/include/storages/parserse_base_utils.h
+++ b/contrib/epee/include/storages/parserse_base_utils.h
@@ -28,6 +28,8 @@
#pragma once
+#include <algorithm>
+
namespace epee
{
namespace misc_utils
@@ -36,8 +38,12 @@ namespace misc_utils
{
inline std::string transform_to_escape_sequence(const std::string& src)
{
- //std::stringstream res;
+ 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())
+ return src;
+
std::string res;
+ res.reserve(2 * src.size());
for(std::string::const_iterator it = src.begin(); it!=src.end(); ++it)
{
switch(*it)
@@ -84,6 +90,7 @@ 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;