diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2017-08-01 14:38:08 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2017-08-01 14:38:08 +0000 |
commit | 295cf4de37a4be7de2c9fa424da381cbb15df478 (patch) | |
tree | cd8b38ccee463789c9baf51f02e2955d74ebcf18 | |
parent | 442e722c1e09a5370728ba7b307d90d28e9b4fa1 (diff) | |
download | bcm5719-llvm-295cf4de37a4be7de2c9fa424da381cbb15df478.tar.gz bcm5719-llvm-295cf4de37a4be7de2c9fa424da381cbb15df478.zip |
[DebugInfo] Use shrink_to_fit to simplify code. NFCI.
llvm-svn: 309683
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 14 |
2 files changed, 4 insertions, 14 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp index 65c486a6cf3..a3ecb15e366 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp @@ -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 { diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index f55ece2fdfd..0a12fb2ecaa 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -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(); } } |