diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-04-22 10:23:20 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-04-22 10:23:20 +0200 |
commit | 53857552278173641c0489a3196c51aab769bac8 (patch) | |
tree | 35cfdb7fcaac61a187fdabbc508afdc0f38b1606 /src/libutil/compression.cc | |
parent | a6eebcff36164735ff4523012d65c96ca497c905 (diff) |
Remove makeDecompressionSource()
This function doesn't support all compression methods (i.e. 'none' and
'br') so it shouldn't be exposed.
Also restore the original decompress() as a wrapper around
makeDecompressionSink().
Diffstat (limited to 'src/libutil/compression.cc')
-rw-r--r-- | src/libutil/compression.cc | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc index c5dae42fa..7e725cae1 100644 --- a/src/libutil/compression.cc +++ b/src/libutil/compression.cc @@ -186,19 +186,11 @@ struct BrotliDecompressionSink : ChunkedCompressionSink ref<std::string> decompress(const std::string & method, const std::string & in) { - if (method == "none" || method == "") - return make_ref<std::string>(in); - else if (method == "br") { - StringSink ssink; - auto sink = makeDecompressionSink(method, ssink); - (*sink)(in); - sink->finish(); - return ssink.s; - } else { - StringSource ssrc(in); - auto src = makeDecompressionSource(ssrc); - return make_ref<std::string>(src->drain()); - } + StringSink ssink; + auto sink = makeDecompressionSink(method, ssink); + (*sink)(in); + sink->finish(); + return ssink.s; } std::unique_ptr<FinishSink> makeDecompressionSink(const std::string & method, Sink & nextSink) @@ -209,7 +201,7 @@ std::unique_ptr<FinishSink> makeDecompressionSink(const std::string & method, Si return std::make_unique<BrotliDecompressionSink>(nextSink); else return sourceToSink([&](Source & source) { - auto decompressionSource = makeDecompressionSource(source); + auto decompressionSource = std::make_unique<ArchiveDecompressionSource>(source); decompressionSource->drainInto(nextSink); }); } @@ -267,11 +259,6 @@ struct BrotliCompressionSink : ChunkedCompressionSink } }; -std::unique_ptr<Source> makeDecompressionSource(Source & prev) -{ - return std::unique_ptr<Source>(new ArchiveDecompressionSource(prev)); -} - ref<CompressionSink> makeCompressionSink(const std::string & method, Sink & nextSink, const bool parallel) { std::vector<std::string> la_supports = { |