fix: remove duplicate logic

This commit is contained in:
YiFang Xiao 2023-06-09 21:36:12 +08:00
parent 8ecf3b6cbc
commit 04ed15434e

View file

@ -989,21 +989,19 @@ DslScanner::~DslScanner() noexcept
bool DslScanner::readNextLine( wstring & out, size_t & offset, bool only_head_word )
{
offset = (size_t)( gztell( f ) - readBufferLeft/*+pos*/ );
offset = gztell( f ) - readBufferLeft/*+pos*/;
for(;;)
{
for ( ;; ) {
// Check that we have bytes to read
if ( readBufferLeft < 5000 )
{
if ( !gzeof( f ) )
{
if ( readBufferLeft < 5000 ) {
if ( !gzeof( f ) ) {
// To avoid having to deal with ring logic, we move the remaining bytes
// to the beginning
memmove( readBuffer, readBufferPtr, readBufferLeft );
// Read some more bytes to readBuffer
int result = gzread( f, readBuffer + readBufferLeft,
const int result = gzread( f,
readBuffer + readBufferLeft,
sizeof( readBuffer ) - readBufferLeft );
if ( result == -1 )
@ -1030,18 +1028,12 @@ bool DslScanner::readNextLine( wstring & out, size_t & offset, bool only_head_wo
linesRead++;
if ( only_head_word && ( line.isEmpty() || line.at( 0 ).isSpace() ) )
continue;
#ifdef __WIN32
out = line.toStdU32String();
#else
out=line.toStdU32String();
#endif
return true;
}
}
bool DslScanner::readNextLineWithoutComments( wstring & out, size_t & offset, bool only_headword )
{
wstring str;
bool commentToNextLine = false;
@ -1294,8 +1286,8 @@ void expandTildes( wstring & str, wstring const & tildeReplacement )
if( x > 0 && str[ x - 1 ] == '^' && ( x < 2 || str[ x - 2 ] != '\\' ) )
{
str.replace( x - 1, 2, tildeValue );
str[ x - 1 ] = QChar( str[ x - 1 ] ).isUpper() ? QChar::toLower( (uint)str[ x - 1 ] )
: QChar::toUpper( (uint)str[ x - 1 ] );
str[ x - 1 ] = QChar( str[ x - 1 ] ).isUpper() ? QChar::toLower( str[ x - 1 ] )
: QChar::toUpper( str[ x - 1 ] );
x = x - 1 + tildeValue.size();
}
else