aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/serialization
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/epee/include/serialization')
-rw-r--r--contrib/epee/include/serialization/keyvalue_serialization.h2
-rw-r--r--contrib/epee/include/serialization/keyvalue_serialization_overloads.h24
2 files changed, 9 insertions, 17 deletions
diff --git a/contrib/epee/include/serialization/keyvalue_serialization.h b/contrib/epee/include/serialization/keyvalue_serialization.h
index 78d294d05..fd343865c 100644
--- a/contrib/epee/include/serialization/keyvalue_serialization.h
+++ b/contrib/epee/include/serialization/keyvalue_serialization.h
@@ -89,6 +89,8 @@ public: \
#define KV_SERIALIZE_OPT_N(variable, val_name, default_value) \
do { \
+ if (is_store && this_ref.variable == default_value) \
+ break; \
if (!epee::serialization::selector<is_store>::serialize(this_ref.variable, stg, hparent_section, val_name)) \
epee::serialize_default(this_ref.variable, default_value); \
} while (0);
diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
index fc8b90a2c..1f9d6b6d7 100644
--- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
+++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
@@ -48,22 +48,10 @@ namespace epee
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
- static bool serialize_t_val(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
- {
- return stg.set_value(pname, d, hparent_section);
- }
- //-------------------------------------------------------------------------------------------------------------------
- template<class t_type, class t_storage>
- static bool unserialize_t_val(t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
- {
- return stg.get_value(pname, d, hparent_section);
- }
- //-------------------------------------------------------------------------------------------------------------------
- template<class t_type, class t_storage>
static bool serialize_t_val_as_blob(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
std::string blob((const char *)&d, sizeof(d));
- return stg.set_value(pname, blob, hparent_section);
+ return stg.set_value(pname, std::move(blob), hparent_section);
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
@@ -114,13 +102,15 @@ namespace epee
template<class stl_container, class t_storage>
static bool serialize_stl_container_t_val (const stl_container& container, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
+ using value_type = typename stl_container::value_type;
+
if(!container.size()) return true;
typename stl_container::const_iterator it = container.begin();
- typename t_storage::harray hval_array = stg.insert_first_value(pname, *it, hparent_section);
+ typename t_storage::harray hval_array = stg.insert_first_value(pname, value_type(*it), hparent_section);
CHECK_AND_ASSERT_MES(hval_array, false, "failed to insert first value to storage");
it++;
for(;it!= container.end();it++)
- stg.insert_next_value(hval_array, *it);
+ stg.insert_next_value(hval_array, value_type(*it));
return true;
}
@@ -149,7 +139,7 @@ namespace epee
*p_elem = v;
p_elem++;
}
- return stg.set_value(pname, mb, hparent_section);
+ return stg.set_value(pname, std::move(mb), hparent_section);
}
//--------------------------------------------------------------------------------------------------------------------
template<class stl_container, class t_storage>
@@ -221,7 +211,7 @@ namespace epee
template<class t_type, class t_storage>
static bool kv_serialize(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
- return stg.set_value(pname, d, hparent_section);
+ return stg.set_value(pname, t_type(d), hparent_section);
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>