From 6f304dee384d28651797e4ea43569014aa72de64 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 2 Jun 2020 21:49:20 -0700 Subject: [PATCH] [clang-tidy] use auto Found with modernize-use-auto Signed-off-by: Rosen Penev --- src/directives.cpp | 2 +- src/node_data.cpp | 13 ++++++------- src/nodeevents.cpp | 4 ++-- src/singledocparser.cpp | 2 +- src/stream.cpp | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/directives.cpp b/src/directives.cpp index 0c85d0f..f6e9587 100644 --- a/src/directives.cpp +++ b/src/directives.cpp @@ -5,7 +5,7 @@ Directives::Directives() : version{true, 1, 2}, tags{} {} const std::string Directives::TranslateTagHandle( const std::string& handle) const { - std::map::const_iterator it = tags.find(handle); + auto it = tags.find(handle); if (it == tags.end()) { if (handle == "!!") return "tag:yaml.org,2002:"; diff --git a/src/node_data.cpp b/src/node_data.cpp index f8c41a5..d8f6709 100644 --- a/src/node_data.cpp +++ b/src/node_data.cpp @@ -109,9 +109,9 @@ void node_data::compute_seq_size() const { } void node_data::compute_map_size() const { - kv_pairs::iterator it = m_undefinedPairs.begin(); + auto it = m_undefinedPairs.begin(); while (it != m_undefinedPairs.end()) { - kv_pairs::iterator jt = std::next(it); + auto jt = std::next(it); if (it->first->is_defined() && it->second->is_defined()) m_undefinedPairs.erase(it); it = jt; @@ -209,7 +209,7 @@ node* node_data::get(node& key, shared_memory_holder /* pMemory */) const { return nullptr; } - for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { + for (auto it = m_map.begin(); it != m_map.end(); ++it) { if (it->first->is(key)) return it->second; } @@ -244,15 +244,14 @@ bool node_data::remove(node& key, shared_memory_holder /* pMemory */) { if (m_type != NodeType::Map) return false; - for (kv_pairs::iterator it = m_undefinedPairs.begin(); - it != m_undefinedPairs.end();) { - kv_pairs::iterator jt = std::next(it); + for (auto it = m_undefinedPairs.begin(); it != m_undefinedPairs.end();) { + auto jt = std::next(it); if (it->first->is(key)) m_undefinedPairs.erase(it); it = jt; } - for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) { + for (auto it = m_map.begin(); it != m_map.end(); ++it) { if (it->first->is(key)) { m_map.erase(it); return true; diff --git a/src/nodeevents.cpp b/src/nodeevents.cpp index b7222e0..ec62025 100644 --- a/src/nodeevents.cpp +++ b/src/nodeevents.cpp @@ -13,7 +13,7 @@ void NodeEvents::AliasManager::RegisterReference(const detail::node& node) { anchor_t NodeEvents::AliasManager::LookupAnchor( const detail::node& node) const { - AnchorByIdentity::const_iterator it = m_anchorByIdentity.find(node.ref()); + auto it = m_anchorByIdentity.find(node.ref()); if (it == m_anchorByIdentity.end()) return 0; return it->second; @@ -95,7 +95,7 @@ void NodeEvents::Emit(const detail::node& node, EventHandler& handler, } bool NodeEvents::IsAliased(const detail::node& node) const { - RefCount::const_iterator it = m_refCount.find(node.ref()); + auto it = m_refCount.find(node.ref()); return it != m_refCount.end() && it->second > 1; } } // namespace YAML diff --git a/src/singledocparser.cpp b/src/singledocparser.cpp index c8f75e0..5e00515 100644 --- a/src/singledocparser.cpp +++ b/src/singledocparser.cpp @@ -422,7 +422,7 @@ anchor_t SingleDocParser::RegisterAnchor(const std::string& name) { anchor_t SingleDocParser::LookupAnchor(const Mark& mark, const std::string& name) const { - Anchors::const_iterator it = m_anchors.find(name); + auto it = m_anchors.find(name); if (it == m_anchors.end()) throw ParserException(mark, ErrorMsg::UNKNOWN_ANCHOR); diff --git a/src/stream.cpp b/src/stream.cpp index b1aa092..721cc18 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -151,7 +151,7 @@ inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) { inline char Utf8Adjust(unsigned long ch, unsigned char lead_bits, unsigned char rshift) { - const unsigned char header = + const auto header = static_cast(((1 << lead_bits) - 1) << (8 - lead_bits)); const unsigned char mask = (0xFF >> (lead_bits + 1)); return static_cast(