mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
GzipNoCompression witout zlib calls
This commit is contained in:
parent
e301387896
commit
1eead0e885
3 changed files with 25 additions and 7 deletions
|
@ -1212,14 +1212,12 @@ namespace stream
|
|||
const uint8_t * payload, size_t len, uint16_t toPort, bool checksum)
|
||||
{
|
||||
auto msg = m_I2NPMsgsPool.AcquireShared ();
|
||||
if (!m_Gzip || len <= i2p::stream::COMPRESSION_THRESHOLD_SIZE)
|
||||
m_Deflator.SetCompressionLevel (Z_NO_COMPRESSION);
|
||||
else
|
||||
m_Deflator.SetCompressionLevel (Z_DEFAULT_COMPRESSION);
|
||||
uint8_t * buf = msg->GetPayload ();
|
||||
buf += 4; // reserve for lengthlength
|
||||
msg->len += 4;
|
||||
size_t size = m_Deflator.Deflate (payload, len, buf, msg->maxLen - msg->len);
|
||||
size_t size = (!m_Gzip || len <= i2p::stream::COMPRESSION_THRESHOLD_SIZE)?
|
||||
i2p::data::GzipNoCompression (payload, len, buf, msg->maxLen - msg->len):
|
||||
m_Deflator.Deflate (payload, len, buf, msg->maxLen - msg->len);
|
||||
if (size)
|
||||
{
|
||||
htobe32buf (msg->GetPayload (), size); // length
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue