[Lldb-commits] [lldb] r254757 - Improve the std::list data formatter to not need to calculate indices for every loop iteration

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 4 11:48:08 PST 2015


Author: enrico
Date: Fri Dec  4 13:48:08 2015
New Revision: 254757

URL: http://llvm.org/viewvc/llvm-project?rev=254757&view=rev
Log:
Improve the std::list data formatter to not need to calculate indices for every loop iteration

This saves about 5 seconds on a 1500 elements list from my local estimates


Modified:
    lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp?rev=254757&r1=254756&r2=254757&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp Fri Dec  4 13:48:08 2015
@@ -31,6 +31,9 @@ namespace {
 
     class ListEntry
     {
+    private:
+        static const std::initializer_list<size_t> __prev_idx;
+        static const std::initializer_list<size_t> __next_idx;
     public:
         ListEntry() = default;
         ListEntry (ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {}
@@ -42,7 +45,7 @@ namespace {
         {
             if (!m_entry_sp)
                 return ListEntry();
-            return ListEntry(m_entry_sp->GetChildMemberWithName(ConstString("__next_"), true));
+            return ListEntry(m_entry_sp->GetChildAtIndexPath({0,1}));
         }
 
         ListEntry
@@ -50,7 +53,7 @@ namespace {
         {
             if (!m_entry_sp)
                 return ListEntry();
-            return ListEntry(m_entry_sp->GetChildMemberWithName(ConstString("__prev_"), true));
+            return ListEntry(m_entry_sp->GetChildAtIndexPath({0,0}));
         }
 
         uint64_t
@@ -321,7 +324,7 @@ lldb_private::formatters::LibcxxStdListS
     ValueObjectSP current_sp(current.advance(idx));
     if (!current_sp)
         return lldb::ValueObjectSP();
-    current_sp = current_sp->GetChildMemberWithName(ConstString("__value_"), true);
+    current_sp = current_sp->GetChildAtIndex(1, true); // get the __value_ child
     if (!current_sp)
         return lldb::ValueObjectSP();
     // we need to copy current_sp into a new object otherwise we will end up with all items named __value_




More information about the lldb-commits mailing list