From 9060643380b3c66233dbce64489fce1916a48d98 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sat, 14 Sep 2019 15:46:51 +0000 Subject: [PATCH] [lldb] Code cleanup: FormattersContainer.h: Use range-based for loops. Suggested for an other loop by Pavel Labath in: https://reviews.llvm.org/D66654#inline-605808 llvm-svn: 371922 --- .../lldb/DataFormatters/FormattersContainer.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h index 0c9ddec..0791028 100644 --- a/lldb/include/lldb/DataFormatters/FormattersContainer.h +++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h @@ -114,10 +114,9 @@ public: void ForEach(ForEachCallback callback) { if (callback) { std::lock_guard guard(m_map_mutex); - MapIterator pos, end = m_map.end(); - for (pos = m_map.begin(); pos != end; pos++) { - const KeyType &type = pos->first; - if (!callback(type, pos->second)) + for (const auto &pos : m_map) { + const KeyType &type = pos.first; + if (!callback(type, pos.second)) break; } } @@ -295,11 +294,10 @@ protected: RegularExpression *dummy) { llvm::StringRef key_str = key.GetStringRef(); std::lock_guard guard(m_format_map.mutex()); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) { - const RegularExpression ®ex = pos->first; + for (const auto &pos : m_format_map.map()) { + const RegularExpression ®ex = pos.first; if (regex.Execute(key_str)) { - value = pos->second; + value = pos.second; return true; } } @@ -309,11 +307,10 @@ protected: bool GetExact_Impl(ConstString key, MapValueType &value, RegularExpression *dummy) { std::lock_guard guard(m_format_map.mutex()); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) { - const RegularExpression ®ex = pos->first; + for (const auto &pos : m_format_map.map()) { + const RegularExpression ®ex = pos.first; if (regex.GetText() == key.GetStringRef()) { - value = pos->second; + value = pos.second; return true; } } -- 2.7.4