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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205676 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-04-05 21:26:44 +00:00
parent 48ee81c679
commit b206103abc
5 changed files with 18 additions and 22 deletions

View File

@ -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 =