[Lldb-commits] [lldb] r371922 - [lldb] Code cleanup: FormattersContainer.h: Use range-based for loops.

Jan Kratochvil via lldb-commits lldb-commits at lists.llvm.org
Sat Sep 14 08:46:51 PDT 2019


Author: jankratochvil
Date: Sat Sep 14 08:46:51 2019
New Revision: 371922

URL: http://llvm.org/viewvc/llvm-project?rev=371922&view=rev
Log:
[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

Modified:
    lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h

Modified: lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h?rev=371922&r1=371921&r2=371922&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h Sat Sep 14 08:46:51 2019
@@ -114,10 +114,9 @@ public:
   void ForEach(ForEachCallback callback) {
     if (callback) {
       std::lock_guard<std::recursive_mutex> 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<std::recursive_mutex> 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 &regex = pos->first;
+    for (const auto &pos : m_format_map.map()) {
+      const RegularExpression &regex = 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<std::recursive_mutex> 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 &regex = pos->first;
+    for (const auto &pos : m_format_map.map()) {
+      const RegularExpression &regex = pos.first;
       if (regex.GetText() == key.GetStringRef()) {
-        value = pos->second;
+        value = pos.second;
         return true;
       }
     }




More information about the lldb-commits mailing list