[Lldb-commits] [lldb] r333636 - Simplify DWARFUnit::m_die_array swap() to use shrink_to_fit()

Jan Kratochvil via lldb-commits lldb-commits at lists.llvm.org
Thu May 31 01:55:40 PDT 2018


Author: jankratochvil
Date: Thu May 31 01:55:40 2018
New Revision: 333636

URL: http://llvm.org/viewvc/llvm-project?rev=333636&view=rev
Log:
Simplify DWARFUnit::m_die_array swap() to use shrink_to_fit()

rL145086 introduced m_die_array.shrink_to_fit() implemented by
exact_size_die_array.swap, it was before LLVM became written in C++11.

Differential revision: https://reviews.llvm.org/D47492

Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp?rev=333636&r1=333635&r2=333636&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp Thu May 31 01:55:40 2018
@@ -180,15 +180,7 @@ bool DWARFUnit::ExtractDIEsIfNeeded() {
     m_first_die = m_die_array.front();
   }
 
-  // Since std::vector objects will double their size, we really need to make a
-  // new array with the perfect size so we don't end up wasting space. So here
-  // we copy and swap to make sure we don't have any extra memory taken up.
-
-  if (m_die_array.size() < m_die_array.capacity()) {
-    DWARFDebugInfoEntry::collection exact_size_die_array(m_die_array.begin(),
-                                                         m_die_array.end());
-    exact_size_die_array.swap(m_die_array);
-  }
+  m_die_array.shrink_to_fit();
 
   ExtractDIEsEndCheck(offset);
 




More information about the lldb-commits mailing list