diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-05-13 18:06:47 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-05-13 18:06:47 +0200 |
commit | f3e741dad1311e0b4057b530386e246f921be52c (patch) | |
tree | 64581e3f0ddfa9d4740eed7b545fe3db87b8c126 /src/nodemetadata.cpp | |
parent | 96a37aed31cfb9c131e46eda80bdbe3d2289a546 (diff) | |
parent | 69c70dd319532f7860f211f4a527a902b0386e49 (diff) | |
download | dragonfireclient-f3e741dad1311e0b4057b530386e246f921be52c.tar.xz |
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'src/nodemetadata.cpp')
-rw-r--r-- | src/nodemetadata.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/nodemetadata.cpp b/src/nodemetadata.cpp index 6447c8785..f98732385 100644 --- a/src/nodemetadata.cpp +++ b/src/nodemetadata.cpp @@ -206,10 +206,9 @@ NodeMetadataList::~NodeMetadataList() std::vector<v3s16> NodeMetadataList::getAllKeys() { std::vector<v3s16> keys; - - NodeMetadataMap::const_iterator it; - for (it = m_data.begin(); it != m_data.end(); ++it) - keys.push_back(it->first); + keys.reserve(m_data.size()); + for (const auto &it : m_data) + keys.push_back(it.first); return keys; } @@ -218,7 +217,7 @@ NodeMetadata *NodeMetadataList::get(v3s16 p) { NodeMetadataMap::const_iterator n = m_data.find(p); if (n == m_data.end()) - return NULL; + return nullptr; return n->second; } @@ -235,7 +234,7 @@ void NodeMetadataList::remove(v3s16 p) void NodeMetadataList::set(v3s16 p, NodeMetadata *d) { remove(p); - m_data.insert(std::make_pair(p, d)); + m_data.emplace(p, d); } void NodeMetadataList::clear() @@ -251,9 +250,8 @@ void NodeMetadataList::clear() int NodeMetadataList::countNonEmpty() const { int n = 0; - NodeMetadataMap::const_iterator it; - for (it = m_data.begin(); it != m_data.end(); ++it) { - if (!it->second->empty()) + for (const auto &it : m_data) { + if (!it.second->empty()) n++; } return n; |