From 9458029eed2ff17027b92beba3db4db051c5aa59 Mon Sep 17 00:00:00 2001 From: "zhuna.1024" Date: Mon, 29 Aug 2022 21:36:45 +0800 Subject: [PATCH] remove unreachable else branch --- snappy.cc | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/snappy.cc b/snappy.cc index 6502cfd..2fac33e 100644 --- a/snappy.cc +++ b/snappy.cc @@ -1523,29 +1523,11 @@ size_t Compress(Source* reader, Sink* writer) { const char* fragment = reader->Peek(&fragment_size); assert(fragment_size != 0); // premature end of input const size_t num_to_read = std::min(N, kBlockSize); - size_t bytes_read = fragment_size; size_t pending_advance = 0; - if (bytes_read >= num_to_read) { - // Buffer returned by reader is large enough - pending_advance = num_to_read; - fragment_size = num_to_read; - } else { - char* scratch = wmem.GetScratchInput(); - std::memcpy(scratch, fragment, bytes_read); - reader->Skip(bytes_read); - - while (bytes_read < num_to_read) { - fragment = reader->Peek(&fragment_size); - size_t n = std::min(fragment_size, num_to_read - bytes_read); - std::memcpy(scratch + bytes_read, fragment, n); - bytes_read += n; - reader->Skip(n); - } - assert(bytes_read == num_to_read); - fragment = scratch; - fragment_size = num_to_read; - } + // Buffer returned by reader is large enough + pending_advance = num_to_read; + fragment_size = num_to_read; assert(fragment_size == num_to_read); // Get encoding table for compression