diff options
author | aperkov <aperkov@yandex-team.ru> | 2022-02-10 16:50:55 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:55 +0300 |
commit | 89ea65c80e04230d503a75d528b71ddae5f51af0 (patch) | |
tree | c1af35d2a2105df5355b8f36749efcf8cd137260 | |
parent | 74f244adb5fa85ca0f82ad35f22cfc6218aedcb6 (diff) | |
download | ydb-89ea65c80e04230d503a75d528b71ddae5f51af0.tar.gz |
Restoring authorship annotation for <aperkov@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | library/cpp/streams/lzma/lzma.cpp | 54 | ||||
-rw-r--r-- | library/cpp/streams/lzma/lzma_ut.cpp | 22 |
2 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/streams/lzma/lzma.cpp b/library/cpp/streams/lzma/lzma.cpp index f1942fa546..0610c0c8d8 100644 --- a/library/cpp/streams/lzma/lzma.cpp +++ b/library/cpp/streams/lzma/lzma.cpp @@ -386,23 +386,23 @@ public: private: virtual bool Fill() = 0; - + protected: CLzmaDec H_; char* InBegin_; char* InEnd_; -}; - -class TLzmaDecompress::TImplStream: public TImpl { +}; + +class TLzmaDecompress::TImplStream: public TImpl { public: inline TImplStream(IInputStream* slave) : Slave_(slave) { Byte buf[LZMA_PROPS_SIZE]; - + if (Slave_->Load(buf, sizeof(buf)) != sizeof(buf)) ythrow yexception() << "can't read lzma header"; - + Check(LzmaDec_Allocate(&H_, buf, sizeof(buf), Alloc())); LzmaDec_Init(&H_); } @@ -412,23 +412,23 @@ private: size_t size = Slave_->Read(In_, sizeof(In_)); InBegin_ = In_; InEnd_ = In_ + size; - + return size; } - + private: IInputStream* Slave_; char In_[4096]; }; -class TLzmaDecompress::TImplZeroCopy: public TLzmaDecompress::TImpl { -public: +class TLzmaDecompress::TImplZeroCopy: public TLzmaDecompress::TImpl { +public: inline TImplZeroCopy(IZeroCopyInput* in) - : Input_(in) + : Input_(in) { if (!Fill()) ythrow yexception() << "can't read lzma header"; - + char buf[LZMA_PROPS_SIZE]; char* header; if (InEnd_ - InBegin_ >= LZMA_PROPS_SIZE) { @@ -451,18 +451,18 @@ public: pos += avail; if (!Fill()) { ythrow yexception() << "can't read lzma header"; - } - } - } + } + } + } header = buf; } - + Check(LzmaDec_Allocate(&H_, (Byte*)header, LZMA_PROPS_SIZE, Alloc())); - + LzmaDec_Init(&H_); } - -private: + +private: bool Fill() override { size_t size = Input_->Next(&InBegin_); @@ -474,10 +474,10 @@ private: return false; } - + IZeroCopyInput* Input_; -}; - +}; + TLzmaCompress::TLzmaCompress(IOutputStream* slave, size_t level) : Impl_(new TImpl(slave, level)) { @@ -503,15 +503,15 @@ void TLzmaCompress::DoFinish() { } TLzmaDecompress::TLzmaDecompress(IInputStream* slave) - : Impl_(new TImplStream(slave)) + : Impl_(new TImplStream(slave)) { } TLzmaDecompress::TLzmaDecompress(IZeroCopyInput* input) - : Impl_(new TImplZeroCopy(input)) -{ -} - + : Impl_(new TImplZeroCopy(input)) +{ +} + TLzmaDecompress::~TLzmaDecompress() { } diff --git a/library/cpp/streams/lzma/lzma_ut.cpp b/library/cpp/streams/lzma/lzma_ut.cpp index 847e98d1ca..7d582517c1 100644 --- a/library/cpp/streams/lzma/lzma_ut.cpp +++ b/library/cpp/streams/lzma/lzma_ut.cpp @@ -13,7 +13,7 @@ public: , Pos(s.data()) { } - + private: size_t DoNext(const void** ptr, size_t len) override { if (Pos < Data.end()) { @@ -23,13 +23,13 @@ private: return len; } else { return 0; - } + } } - + TString Data; const char* Pos; -}; - +}; + class TLzmaTest: public TTestBase { UNIT_TEST_SUITE(TLzmaTest); UNIT_TEST(Test1) @@ -99,27 +99,27 @@ private: } UNIT_ASSERT_EQUAL(data, data1); - + data1.clear(); { TMemoryInput mi(res.data(), res.size()); TStringOutput so(data1); TLzmaDecompress d(&mi); - + TransferData(&d, &so); } - + UNIT_ASSERT_EQUAL(data, data1); - + data1.clear(); { TStrokaByOneByte mi(res); TStringOutput so(data1); TLzmaDecompress d(&mi); - + TransferData(&d, &so); } - + UNIT_ASSERT_EQUAL(data, data1); } }; |