Merge "decompressor maintenence" into main

This commit is contained in:
Daniel Zheng 2023-08-09 20:04:07 +00:00 committed by Gerrit Code Review
commit 86f037c245

View file

@ -18,6 +18,7 @@
#include <array>
#include <cstring>
#include <memory>
#include <utility>
#include <vector>
@ -62,6 +63,8 @@ std::unique_ptr<IDecompressor> IDecompressor::FromString(std::string_view compre
return IDecompressor::Brotli();
} else if (compressor == "gz") {
return IDecompressor::Gz();
} else if (compressor == "zstd") {
return IDecompressor::Zstd();
} else {
return nullptr;
}
@ -211,10 +214,6 @@ bool GzDecompressor::PartialDecompress(const uint8_t* data, size_t length) {
return true;
}
std::unique_ptr<IDecompressor> IDecompressor::Gz() {
return std::unique_ptr<IDecompressor>(new GzDecompressor());
}
class BrotliDecompressor final : public StreamDecompressor {
public:
~BrotliDecompressor();
@ -275,10 +274,6 @@ bool BrotliDecompressor::PartialDecompress(const uint8_t* data, size_t length) {
return true;
}
std::unique_ptr<IDecompressor> IDecompressor::Brotli() {
return std::unique_ptr<IDecompressor>(new BrotliDecompressor());
}
class Lz4Decompressor final : public IDecompressor {
public:
~Lz4Decompressor() override = default;
@ -382,6 +377,14 @@ class ZstdDecompressor final : public IDecompressor {
}
};
std::unique_ptr<IDecompressor> IDecompressor::Brotli() {
return std::make_unique<BrotliDecompressor>();
}
std::unique_ptr<IDecompressor> IDecompressor::Gz() {
return std::make_unique<GzDecompressor>();
}
std::unique_ptr<IDecompressor> IDecompressor::Lz4() {
return std::make_unique<Lz4Decompressor>();
}