diff options
| author | David Blaikie <dblaikie@gmail.com> | 2014-04-05 21:26:44 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2014-04-05 21:26:44 +0000 |
| commit | a505f2479e98e50999376e572f905d93428bb93d (patch) | |
| tree | 331b40d708769ec288d04a00cba09e82a1b8e8c4 /llvm/lib/DebugInfo | |
| parent | c12813576c58dadedec2ff722c40e5ff9dd20b84 (diff) | |
| download | bcm5719-llvm-a505f2479e98e50999376e572f905d93428bb93d.tar.gz bcm5719-llvm-a505f2479e98e50999376e572f905d93428bb93d.zip | |
Simplify compression API by decompressing into a SmallVector rather than a MemoryBuffer
This avoids an extra copy during decompression and avoids the use of
MemoryBuffer which is a weirdly esoteric device that includes unrelated
concepts like "file name" (its rather generic name is a bit misleading).
Similar refactoring of zlib::compress coming up.
llvm-svn: 205676
Diffstat (limited to 'llvm/lib/DebugInfo')
| -rw-r--r-- | llvm/lib/DebugInfo/DWARFContext.cpp | 11 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARFContext.h | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/DebugInfo/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARFContext.cpp index 60c5f6ab56d..a287cf9edb2 100644 --- a/llvm/lib/DebugInfo/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARFContext.cpp @@ -637,14 +637,15 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) if (!zlib::isAvailable() || !consumeCompressedDebugSectionHeader(data, OriginalSize)) continue; - std::unique_ptr<MemoryBuffer> UncompressedSection; - if (zlib::uncompress(data, UncompressedSection, OriginalSize) != - zlib::StatusOK) + UncompressedSections.resize(UncompressedSections.size() + 1); + if (zlib::uncompress(data, UncompressedSections.back(), OriginalSize) != + zlib::StatusOK) { + UncompressedSections.pop_back(); continue; + } // Make data point to uncompressed section contents and save its contents. name = name.substr(1); - data = UncompressedSection->getBuffer(); - UncompressedSections.push_back(std::move(UncompressedSection)); + data = UncompressedSections.back(); } StringRef *SectionData = diff --git a/llvm/lib/DebugInfo/DWARFContext.h b/llvm/lib/DebugInfo/DWARFContext.h index ad6841ae9e3..6d1ae921cec 100644 --- a/llvm/lib/DebugInfo/DWARFContext.h +++ b/llvm/lib/DebugInfo/DWARFContext.h @@ -242,7 +242,7 @@ class DWARFContextInMemory : public DWARFContext { StringRef RangeDWOSection; StringRef AddrSection; - SmallVector<std::unique_ptr<MemoryBuffer>, 4> UncompressedSections; + SmallVector<SmallString<32>, 4> UncompressedSections; public: DWARFContextInMemory(object::ObjectFile *); |

