[Lldb-commits] [lldb] bc41b0a - [lldb][Symtab][NFCI] Replace vector::swap with shrink_to_fit (#70918)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 1 03:43:58 PDT 2023
Author: Michael Buch
Date: 2023-11-01T10:43:55Z
New Revision: bc41b0ac2b03b8c305d7399d772c87d27cc9831c
URL: https://github.com/llvm/llvm-project/commit/bc41b0ac2b03b8c305d7399d772c87d27cc9831c
DIFF: https://github.com/llvm/llvm-project/commit/bc41b0ac2b03b8c305d7399d772c87d27cc9831c.diff
LOG: [lldb][Symtab][NFCI] Replace vector::swap with shrink_to_fit (#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
Added:
Modified:
lldb/source/Symbol/Symtab.cpp
Removed:
################################################################################
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();
}
More information about the lldb-commits
mailing list