summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-04-05 21:53:04 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-04-05 21:53:04 +0000
commit857497b9c6362b63b29b7e18af9340befb17ef1b (patch)
tree34d656c0a03c10d4aed0ac9cb3d16f21700a6e09 /llvm/lib/MC/MCAssembler.cpp
parenta505f2479e98e50999376e572f905d93428bb93d (diff)
downloadbcm5719-llvm-857497b9c6362b63b29b7e18af9340befb17ef1b.tar.gz
bcm5719-llvm-857497b9c6362b63b29b7e18af9340befb17ef1b.zip
Simplify compression API by compressing into a SmallVector rather than a MemoryBuffer
This is the other half of r205676. llvm-svn: 205677
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 724ca292bef..ddb543715c7 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -237,23 +237,23 @@ const SmallVectorImpl<char> &MCCompressedFragment::getCompressedContents() const
assert(getParent()->size() == 1 &&
"Only compress sections containing a single fragment");
if (CompressedContents.empty()) {
- std::unique_ptr<MemoryBuffer> CompressedSection;
+ // FIXME: could be more efficient if we let zlib::compress append to a
+ // buffer rather than always from the start.
zlib::Status Success =
zlib::compress(StringRef(getContents().data(), getContents().size()),
- CompressedSection);
+ CompressedContents);
(void)Success;
assert(Success == zlib::StatusOK);
- CompressedContents.push_back('Z');
- CompressedContents.push_back('L');
- CompressedContents.push_back('I');
- CompressedContents.push_back('B');
+ static const StringRef Magic = "ZLIB";
uint64_t Size = getContents().size();
if (sys::IsLittleEndianHost)
Size = sys::SwapByteOrder(Size);
- CompressedContents.append(reinterpret_cast<char *>(&Size),
- reinterpret_cast<char *>(&Size + 1));
- CompressedContents.append(CompressedSection->getBuffer().begin(),
- CompressedSection->getBuffer().end());
+ CompressedContents.insert(CompressedContents.begin(),
+ Magic.size() + sizeof(Size));
+ std::copy(Magic.begin(), Magic.end(), CompressedContents.begin());
+ std::copy(reinterpret_cast<char *>(&Size),
+ reinterpret_cast<char *>(&Size + 1),
+ CompressedContents.begin() + Magic.size());
}
return CompressedContents;
}
OpenPOWER on IntegriCloud