From f94a8eef60c42ed24667076eb702e2a3aa768225 Mon Sep 17 00:00:00 2001 From: Yuri Syrov Date: Wed, 6 Apr 2016 16:39:33 -0700 Subject: [PATCH] Change node_map type from map to list>. This will prevent unpredictable reordering of documents after load and save. --- include/yaml-cpp/node/detail/node_data.h | 2 +- include/yaml-cpp/node/detail/node_iterator.h | 2 +- src/node_data.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/yaml-cpp/node/detail/node_data.h b/include/yaml-cpp/node/detail/node_data.h index 64bbc05..ba11e62 100644 --- a/include/yaml-cpp/node/detail/node_data.h +++ b/include/yaml-cpp/node/detail/node_data.h @@ -114,7 +114,7 @@ class YAML_CPP_API node_data { mutable std::size_t m_seqSize; // map - typedef std::map node_map; + typedef std::list> node_map; node_map m_map; typedef std::pair kv_pair; diff --git a/include/yaml-cpp/node/detail/node_iterator.h b/include/yaml-cpp/node/detail/node_iterator.h index a33049a..012d3e7 100644 --- a/include/yaml-cpp/node/detail/node_iterator.h +++ b/include/yaml-cpp/node/detail/node_iterator.h @@ -37,7 +37,7 @@ struct node_iterator_value : public std::pair { }; typedef std::vector node_seq; -typedef std::map node_map; +typedef std::list> node_map; template struct node_iterator_type { diff --git a/src/node_data.cpp b/src/node_data.cpp index a862946..e33bfc2 100644 --- a/src/node_data.cpp +++ b/src/node_data.cpp @@ -256,9 +256,9 @@ void node_data::reset_map() { } void node_data::insert_map_pair(node& key, node& value) { - m_map[&key] = &value; + m_map.emplace_back(&key, &value); if (!key.is_defined() || !value.is_defined()) - m_undefinedPairs.push_back(kv_pair(&key, &value)); + m_undefinedPairs.emplace_back(&key, &value); } void node_data::convert_to_map(shared_memory_holder pMemory) {