Switched the implementation of maps from list<pair> to map (but just pointer comparison)

This commit is contained in:
beder
2011-09-11 16:56:38 -05:00
parent ad28ffc6f8
commit 9c6bd61398
4 changed files with 7 additions and 9 deletions

View File

@@ -54,7 +54,7 @@ namespace YAML
node& k = convert_to_node(key, pMemory); node& k = convert_to_node(key, pMemory);
node& v = pMemory->create_node(); node& v = pMemory->create_node();
m_map.push_back(kv_pair(&k, &v)); m_map[&k] = &v;
return v; return v;
} }

View File

@@ -86,8 +86,7 @@ namespace YAML
mutable std::size_t m_seqSize; mutable std::size_t m_seqSize;
// map // map
typedef std::pair<node *, node *> kv_pair; typedef std::map<node *, node *> node_map;
typedef std::list<kv_pair> node_map;
node_map m_map; node_map m_map;
}; };
} }

View File

@@ -10,7 +10,7 @@
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <list> #include <map>
#include <utility> #include <utility>
#include <vector> #include <vector>
@@ -35,8 +35,7 @@ namespace YAML
}; };
typedef std::vector<node *> node_seq; typedef std::vector<node *> node_seq;
typedef std::pair<node *, node *> kv_pair; typedef std::map<node *, node *> node_map;
typedef std::list<kv_pair> node_map;
template<typename V> template<typename V>
struct node_iterator_type { struct node_iterator_type {

View File

@@ -166,7 +166,7 @@ namespace YAML
if(m_type != NodeType::Map) if(m_type != NodeType::Map)
throw std::runtime_error("Can't insert into a non-map node"); throw std::runtime_error("Can't insert into a non-map node");
m_map.push_back(kv_pair(&key, &value)); m_map[&key] = &value;
} }
// indexing // indexing
@@ -205,7 +205,7 @@ namespace YAML
} }
node& value = pMemory->create_node(); node& value = pMemory->create_node();
m_map.push_back(kv_pair(&key, &value)); m_map[&key] = &value;
return value; return value;
} }
@@ -246,7 +246,7 @@ namespace YAML
node& key = pMemory->create_node(); node& key = pMemory->create_node();
key.set_scalar(stream.str()); key.set_scalar(stream.str());
m_map.push_back(kv_pair(&key, m_sequence[i])); m_map[&key] = m_sequence[i];
} }
reset_sequence(); reset_sequence();