[Lldb-commits] [lldb] [lldb][Symtab][NFCI] Replace vector::swap with shrink_to_fit (PR #70918)

via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 1 03:32:32 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

<details>
<summary>Changes</summary>

Replaces the old idiom of swapping the container to shrink it, with the newer STL alternative.

Similar transition in LLDB was done in: https://reviews.llvm.org/D47492

---
Full diff: https://github.com/llvm/llvm-project/pull/70918.diff


1 Files Affected:

- (modified) lldb/source/Symbol/Symtab.cpp (+1-4) 


``````````diff
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index 104faac38ffa0fe..1aebe198f9e78ae 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -1010,10 +1010,7 @@ void Symtab::Finalize() {
   // Calculate the size of symbols inside InitAddressIndexes.
   InitAddressIndexes();
   // Shrink to fit the symbols so we don't waste memory
-  if (m_symbols.capacity() > m_symbols.size()) {
-    collection new_symbols(m_symbols.begin(), m_symbols.end());
-    m_symbols.swap(new_symbols);
-  }
+  m_symbols.shrink_to_fit();
   SaveToCache();
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/70918


More information about the lldb-commits mailing list