mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
fix: code smell ,remove while(1)
This commit is contained in:
parent
752b880f24
commit
9842761c1c
|
@ -14,10 +14,9 @@ QByteArray zlibDecompress( const char * bufptr, unsigned length )
|
||||||
memset( &zs, 0, sizeof( zs ) );
|
memset( &zs, 0, sizeof( zs ) );
|
||||||
zs.next_in = (Bytef *)bufptr;
|
zs.next_in = (Bytef *)bufptr;
|
||||||
zs.avail_in = length;
|
zs.avail_in = length;
|
||||||
while ( 1 ) {
|
res = inflateInit( &zs );
|
||||||
res = inflateInit( &zs );
|
|
||||||
if ( res != Z_OK )
|
if ( res == Z_OK ) {
|
||||||
break;
|
|
||||||
while ( res != Z_STREAM_END ) {
|
while ( res != Z_STREAM_END ) {
|
||||||
zs.next_out = (Bytef *)buf;
|
zs.next_out = (Bytef *)buf;
|
||||||
zs.avail_out = CHUNK_SIZE;
|
zs.avail_out = CHUNK_SIZE;
|
||||||
|
@ -26,8 +25,8 @@ QByteArray zlibDecompress( const char * bufptr, unsigned length )
|
||||||
if ( res != Z_OK && res != Z_STREAM_END )
|
if ( res != Z_OK && res != Z_STREAM_END )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inflateEnd( &zs );
|
inflateEnd( &zs );
|
||||||
if ( res != Z_STREAM_END )
|
if ( res != Z_STREAM_END )
|
||||||
str.clear();
|
str.clear();
|
||||||
|
@ -50,10 +49,8 @@ string decompressBzip2( const char * bufptr, unsigned length )
|
||||||
zs.next_in = (char *)bufptr;
|
zs.next_in = (char *)bufptr;
|
||||||
zs.avail_in = length;
|
zs.avail_in = length;
|
||||||
zs.total_in_lo32 = length;
|
zs.total_in_lo32 = length;
|
||||||
while ( 1 ) {
|
res = BZ2_bzDecompressInit( &zs, 0, 0 );
|
||||||
res = BZ2_bzDecompressInit( &zs, 0, 0 );
|
if ( res == BZ_OK ) {
|
||||||
if ( res != BZ_OK )
|
|
||||||
break;
|
|
||||||
while ( res != BZ_STREAM_END ) {
|
while ( res != BZ_STREAM_END ) {
|
||||||
zs.next_out = buf;
|
zs.next_out = buf;
|
||||||
zs.avail_out = CHUNK_SIZE;
|
zs.avail_out = CHUNK_SIZE;
|
||||||
|
@ -63,7 +60,6 @@ string decompressBzip2( const char * bufptr, unsigned length )
|
||||||
if ( res != BZ_OK && res != BZ_STREAM_END )
|
if ( res != BZ_OK && res != BZ_STREAM_END )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
BZ2_bzDecompressEnd( &zs );
|
BZ2_bzDecompressEnd( &zs );
|
||||||
if ( res != BZ_STREAM_END )
|
if ( res != BZ_STREAM_END )
|
||||||
|
@ -92,14 +88,13 @@ string decompressLzma2( const char * bufptr, unsigned length, bool raw_decoder )
|
||||||
filters[ 1 ].id = LZMA_VLI_UNKNOWN;
|
filters[ 1 ].id = LZMA_VLI_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( 1 ) {
|
|
||||||
if ( raw_decoder )
|
|
||||||
res = lzma_raw_decoder( &strm, filters );
|
|
||||||
else
|
|
||||||
res = lzma_stream_decoder( &strm, UINT64_MAX, 0 );
|
|
||||||
|
|
||||||
if ( res != LZMA_OK )
|
if ( raw_decoder )
|
||||||
break;
|
res = lzma_raw_decoder( &strm, filters );
|
||||||
|
else
|
||||||
|
res = lzma_stream_decoder( &strm, UINT64_MAX, 0 );
|
||||||
|
|
||||||
|
if ( res == LZMA_OK ) {
|
||||||
|
|
||||||
while ( res != LZMA_STREAM_END ) {
|
while ( res != LZMA_STREAM_END ) {
|
||||||
strm.next_out = reinterpret_cast< uint8_t * >( buf );
|
strm.next_out = reinterpret_cast< uint8_t * >( buf );
|
||||||
|
@ -112,8 +107,7 @@ string decompressLzma2( const char * bufptr, unsigned length, bool raw_decoder )
|
||||||
lzma_end( &strm );
|
lzma_end( &strm );
|
||||||
if ( res != LZMA_STREAM_END )
|
if ( res != LZMA_STREAM_END )
|
||||||
str.clear();
|
str.clear();
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue