mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-03 17:24:24 +00:00
[lib/Object] - Minor API update for llvm::Decompressor.
I revisited Decompressor API (issue with it was triggered during D32865 review) and found it is probably provides more then we really need. Issue was about next method's signature: Error decompress(SmallString<32> &Out); It is too strict. At first I wanted to change it to decompress(SmallVectorImpl<char> &Out), but then found it is still not flexible because sticks to SmallVector. During reviews was suggested to use templating to simplify code. Patch do that. Differential revision: https://reviews.llvm.org/D33200 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303331 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c40271cb75
commit
3364210093
@ -30,7 +30,10 @@ public:
|
|||||||
|
|
||||||
/// @brief Resize the buffer and uncompress section data into it.
|
/// @brief Resize the buffer and uncompress section data into it.
|
||||||
/// @param Out Destination buffer.
|
/// @param Out Destination buffer.
|
||||||
Error decompress(SmallString<32> &Out);
|
template <class T> Error Decompressor::resizeAndDecompress(T &Out) {
|
||||||
|
Out.resize(DecompressedSize);
|
||||||
|
return decompress({Out.data(), (size_t)DecompressedSize});
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Uncompress section data to raw buffer provided.
|
/// @brief Uncompress section data to raw buffer provided.
|
||||||
/// @param Buffer Destination buffer.
|
/// @param Buffer Destination buffer.
|
||||||
|
@ -979,7 +979,7 @@ Error DWARFContextInMemory::maybeDecompress(const SectionRef &Sec,
|
|||||||
return Decompressor.takeError();
|
return Decompressor.takeError();
|
||||||
|
|
||||||
SmallString<32> Out;
|
SmallString<32> Out;
|
||||||
if (auto Err = Decompressor->decompress(Out))
|
if (auto Err = Decompressor->resizeAndDecompress(Out))
|
||||||
return Err;
|
return Err;
|
||||||
|
|
||||||
UncompressedSections.emplace_back(std::move(Out));
|
UncompressedSections.emplace_back(std::move(Out));
|
||||||
|
@ -88,11 +88,6 @@ bool Decompressor::isCompressedELFSection(uint64_t Flags, StringRef Name) {
|
|||||||
return (Flags & ELF::SHF_COMPRESSED) || isGnuStyle(Name);
|
return (Flags & ELF::SHF_COMPRESSED) || isGnuStyle(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Error Decompressor::decompress(SmallString<32> &Out) {
|
|
||||||
Out.resize(DecompressedSize);
|
|
||||||
return decompress({Out.data(), (size_t)DecompressedSize});
|
|
||||||
}
|
|
||||||
|
|
||||||
Error Decompressor::decompress(MutableArrayRef<char> Buffer) {
|
Error Decompressor::decompress(MutableArrayRef<char> Buffer) {
|
||||||
size_t Size = Buffer.size();
|
size_t Size = Buffer.size();
|
||||||
return zlib::uncompress(SectionData, Buffer.data(), Size);
|
return zlib::uncompress(SectionData, Buffer.data(), Size);
|
||||||
|
@ -373,7 +373,7 @@ handleCompressedSection(std::deque<SmallString<32>> &UncompressedSections,
|
|||||||
return createError(Name, Dec.takeError());
|
return createError(Name, Dec.takeError());
|
||||||
|
|
||||||
UncompressedSections.emplace_back();
|
UncompressedSections.emplace_back();
|
||||||
if (Error E = Dec->decompress(UncompressedSections.back()))
|
if (Error E = Dec->resizeAndDecompress(UncompressedSections.back()))
|
||||||
return createError(Name, std::move(E));
|
return createError(Name, std::move(E));
|
||||||
|
|
||||||
Name = Name.substr(2); // Drop ".z"
|
Name = Name.substr(2); // Drop ".z"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user