aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-09-04 13:19:58 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-09-04 13:19:58 -0500
commit77ed11e62707e00e74e5f2c599b811719b7aaaa0 (patch)
tree41c89eb9493abb3d2dfba1684bb98ae03f5ff602 /contrib/epee
parentMerge pull request #4269 (diff)
parentwallet2: ask for a binary output distribution, for speed (diff)
downloadmonero-77ed11e62707e00e74e5f2c599b811719b7aaaa0.tar.xz
Merge pull request #4270
29dea03 epee: resize vectors where possible in serialization (moneromooo-monero) 76affd9 epee: some speedup in parsing (moneromooo-monero) dc6c069 db_lmdb: speedup the get_output_distribution common case (moneromooo-monero) 76ac5a8 wallet2: ask for a binary output distribution, for speed (moneromooo-monero)
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/serialization/keyvalue_serialization_overloads.h6
-rw-r--r--contrib/epee/include/storages/parserse_base_utils.h9
2 files changed, 14 insertions, 1 deletions
diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
index 09087f785..15c95f07a 100644
--- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
+++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
@@ -35,6 +35,11 @@
namespace epee
{
+ namespace
+ {
+ template<class C> void hint_resize(C &container, size_t size) {}
+ template<class C> void hint_resize(std::vector<C> &container, size_t size) { container.reserve(size); }
+ }
namespace serialization
{
@@ -158,6 +163,7 @@ namespace epee
false,
"size in blob " << loaded_size << " not have not zero modulo for sizeof(value_type) = " << sizeof(typename stl_container::value_type) << ", type " << typeid(typename stl_container::value_type).name());
size_t count = (loaded_size/sizeof(typename stl_container::value_type));
+ hint_resize(container, count);
for(size_t i = 0; i < count; i++)
container.insert(container.end(), *(pelem++));
}
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;