Use protobuf’s Gzip{Input,Output}Stream wrapper around zlib
This removes our direct zlib dependency (although of course protobuf still uses it internally), removes a fixed 4 MiB buffer and its corresponding limit on the terminal size, reduces some string copying, and deletes some code. Signed-off-by: Anders Kaseorg <andersk@mit.edu> (Closes #230.)
This commit is contained in:
committed by
Keith Winstein
parent
76f5b593d9
commit
b6736eb0a5
@@ -1,32 +0,0 @@
|
||||
#include <zlib.h>
|
||||
|
||||
#include "compressor.h"
|
||||
#include "dos_assert.h"
|
||||
|
||||
using namespace Network;
|
||||
using namespace std;
|
||||
|
||||
string Compressor::compress_str( const string &input )
|
||||
{
|
||||
long unsigned int len = BUFFER_SIZE;
|
||||
dos_assert( Z_OK == compress( buffer, &len,
|
||||
reinterpret_cast<const unsigned char *>( input.data() ),
|
||||
input.size() ) );
|
||||
return string( reinterpret_cast<char *>( buffer ), len );
|
||||
}
|
||||
|
||||
string Compressor::uncompress_str( const string &input )
|
||||
{
|
||||
long unsigned int len = BUFFER_SIZE;
|
||||
dos_assert( Z_OK == uncompress( buffer, &len,
|
||||
reinterpret_cast<const unsigned char *>( input.data() ),
|
||||
input.size() ) );
|
||||
return string( reinterpret_cast<char *>( buffer ), len );
|
||||
}
|
||||
|
||||
/* construct on first use */
|
||||
Compressor & Network::get_compressor( void )
|
||||
{
|
||||
static Compressor the_compressor;
|
||||
return the_compressor;
|
||||
}
|
||||
Reference in New Issue
Block a user