From 3c550cad78870d17b3553c1b3003375cc09ca2e8 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 2 Jun 2020 21:50:32 -0700 Subject: [PATCH] [clang-tidy] convert to range loops Found with modernize-loop-convert Signed-off-by: Rosen Penev --- src/node_data.cpp | 12 ++++++------ src/nodeevents.cpp | 9 ++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/node_data.cpp b/src/node_data.cpp index d8f6709..5973946 100644 --- a/src/node_data.cpp +++ b/src/node_data.cpp @@ -209,9 +209,9 @@ node* node_data::get(node& key, shared_memory_holder /* pMemory */) const { return nullptr; } - for (auto it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->is(key)) - return it->second; + for (const auto& it : m_map) { + if (it.first->is(key)) + return it.second; } return nullptr; @@ -230,9 +230,9 @@ node& node_data::get(node& key, shared_memory_holder pMemory) { throw BadSubscript(m_mark, key); } - for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->is(key)) - return *it->second; + for (const auto& it : m_map) { + if (it.first->is(key)) + return *it.second; } node& value = pMemory->create_node(); diff --git a/src/nodeevents.cpp b/src/nodeevents.cpp index ec62025..07e7038 100644 --- a/src/nodeevents.cpp +++ b/src/nodeevents.cpp @@ -32,8 +32,8 @@ void NodeEvents::Setup(const detail::node& node) { return; if (node.type() == NodeType::Sequence) { - for (detail::const_node_iterator it = node.begin(); it != node.end(); ++it) - Setup(**it); + for (const auto& it : node) + Setup(*it); } else if (node.type() == NodeType::Map) { for (detail::const_node_iterator it = node.begin(); it != node.end(); ++it) { @@ -77,9 +77,8 @@ void NodeEvents::Emit(const detail::node& node, EventHandler& handler, break; case NodeType::Sequence: handler.OnSequenceStart(Mark(), node.tag(), anchor, node.style()); - for (detail::const_node_iterator it = node.begin(); it != node.end(); - ++it) - Emit(**it, handler, am); + for (const auto& it : node) + Emit(*it, handler, am); handler.OnSequenceEnd(); break; case NodeType::Map: