[llvm] r309683 - [DebugInfo] Use shrink_to_fit to simplify code. NFCI.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 1 07:38:08 PDT 2017
Author: d0k
Date: Tue Aug 1 07:38:08 2017
New Revision: 309683
URL: http://llvm.org/viewvc/llvm-project?rev=309683&view=rev
Log:
[DebugInfo] Use shrink_to_fit to simplify code. NFCI.
Modified:
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp?rev=309683&r1=309682&r2=309683&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp Tue Aug 1 07:38:08 2017
@@ -107,8 +107,8 @@ void DWARFDebugAranges::construct() {
assert(ValidCUs.empty());
// Endpoints are not needed now.
- std::vector<RangeEndpoint> EmptyEndpoints;
- EmptyEndpoints.swap(Endpoints);
+ Endpoints.clear();
+ Endpoints.shrink_to_fit();
}
uint32_t DWARFDebugAranges::findAddress(uint64_t Address) const {
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=309683&r1=309682&r2=309683&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Tue Aug 1 07:38:08 2017
@@ -307,18 +307,8 @@ bool DWARFUnit::parseDWO() {
void DWARFUnit::clearDIEs(bool KeepCUDie) {
if (DieArray.size() > (unsigned)KeepCUDie) {
- // std::vectors never get any smaller when resized to a smaller size,
- // or when clear() or erase() are called, the size will report that it
- // is smaller, but the memory allocated remains intact (call capacity()
- // to see this). So we need to create a temporary vector and swap the
- // contents which will cause just the internal pointers to be swapped
- // so that when temporary vector goes out of scope, it will destroy the
- // contents.
- std::vector<DWARFDebugInfoEntry> TmpArray;
- DieArray.swap(TmpArray);
- // Save at least the compile unit DIE
- if (KeepCUDie)
- DieArray.push_back(TmpArray.front());
+ DieArray.resize((unsigned)KeepCUDie);
+ DieArray.shrink_to_fit();
}
}
More information about the llvm-commits
mailing list