Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '7zip/Common/MSBFEncoder.h')
-rwxr-xr-x7zip/Common/MSBFEncoder.h22
1 files changed, 9 insertions, 13 deletions
diff --git a/7zip/Common/MSBFEncoder.h b/7zip/Common/MSBFEncoder.h
index 150988c2..0d1812a3 100755
--- a/7zip/Common/MSBFEncoder.h
+++ b/7zip/Common/MSBFEncoder.h
@@ -37,21 +37,17 @@ public:
{
while(numBits > 0)
{
- int numNewBits = MyMin(numBits, m_BitPos);
- numBits -= numNewBits;
-
- m_CurByte <<= numNewBits;
- UInt32 newBits = value >> numBits;
- m_CurByte |= Byte(newBits);
- value -= (newBits << numBits);
-
- m_BitPos -= numNewBits;
-
- if (m_BitPos == 0)
+ if (numBits < m_BitPos)
{
- m_Stream.WriteByte(m_CurByte);
- m_BitPos = 8;
+ m_CurByte |= ((Byte)value << (m_BitPos -= numBits));
+ return;
}
+ numBits -= m_BitPos;
+ UInt32 newBits = (value >> numBits);
+ value -= (newBits << numBits);
+ m_Stream.WriteByte(m_CurByte | (Byte)newBits);
+ m_BitPos = 8;
+ m_CurByte = 0;
}
}
UInt64 GetProcessedSize() const {