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

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

>From 52c5caf0c352fc13377e56367cc6935e3d9c8c3f Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuc...@gmail.com>
Date: Wed, 1 Nov 2023 10:29:20 +0000
Subject: [PATCH] [lldb][Symtab][NFCI] Replace vector::swap with shrink_to_fit

---
 lldb/source/Symbol/Symtab.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

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();
 }
 

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to