From 53857552278173641c0489a3196c51aab769bac8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 22 Apr 2021 10:23:20 +0200 Subject: [PATCH] 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(). --- src/libutil/compression.cc | 25 ++++++------------------- src/libutil/compression.hh | 2 -- 2 files changed, 6 insertions(+), 21 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 decompress(const std::string & method, const std::string & in) { - if (method == "none" || method == "") - return make_ref(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(src->drain()); - } + StringSink ssink; + auto sink = makeDecompressionSink(method, ssink); + (*sink)(in); + sink->finish(); + return ssink.s; } std::unique_ptr makeDecompressionSink(const std::string & method, Sink & nextSink) @@ -209,7 +201,7 @@ std::unique_ptr makeDecompressionSink(const std::string & method, Si return std::make_unique(nextSink); else return sourceToSink([&](Source & source) { - auto decompressionSource = makeDecompressionSource(source); + auto decompressionSource = std::make_unique(source); decompressionSource->drainInto(nextSink); }); } @@ -267,11 +259,6 @@ struct BrotliCompressionSink : ChunkedCompressionSink } }; -std::unique_ptr makeDecompressionSource(Source & prev) -{ - return std::unique_ptr(new ArchiveDecompressionSource(prev)); -} - ref makeCompressionSink(const std::string & method, Sink & nextSink, const bool parallel) { std::vector la_supports = { diff --git a/src/libutil/compression.hh b/src/libutil/compression.hh index a140f8be2..338a0d9f2 100644 --- a/src/libutil/compression.hh +++ b/src/libutil/compression.hh @@ -15,8 +15,6 @@ struct CompressionSink : BufferedSink, FinishSink using FinishSink::finish; }; -std::unique_ptr makeDecompressionSource(Source & prev); - ref decompress(const std::string & method, const std::string & in); std::unique_ptr makeDecompressionSink(const std::string & method, Sink & nextSink);