mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Full-text search: Skip some text conversions while load article from Zim and Aard dictionaries
This commit is contained in:
parent
8a9378c5d8
commit
fb19fb183e
11
aard.cc
11
aard.cc
|
@ -287,7 +287,8 @@ private:
|
|||
|
||||
/// Loads the article.
|
||||
void loadArticle( quint32 address,
|
||||
string & articleText );
|
||||
string & articleText,
|
||||
bool rawText = false );
|
||||
string convert( string const & in_data );
|
||||
|
||||
friend class AardArticleRequest;
|
||||
|
@ -411,7 +412,8 @@ string AardDictionary::convert( const string & in )
|
|||
}
|
||||
|
||||
void AardDictionary::loadArticle( quint32 address,
|
||||
string & articleText )
|
||||
string & articleText,
|
||||
bool rawText )
|
||||
{
|
||||
quint32 articleOffset = address;
|
||||
quint32 articleSize;
|
||||
|
@ -509,7 +511,12 @@ void AardDictionary::loadArticle( quint32 address,
|
|||
}
|
||||
|
||||
if( !articleText.empty() )
|
||||
{
|
||||
if( rawText )
|
||||
return;
|
||||
|
||||
articleText = convert( articleText );
|
||||
}
|
||||
else
|
||||
articleText = string( QObject::tr( "Article decoding error" ).toUtf8().constData() );
|
||||
|
||||
|
|
16
zim.cc
16
zim.cc
|
@ -321,6 +321,8 @@ bool indexIsOldOrBad( string const & indexFile )
|
|||
quint32 readArticle( ZimFile & file, ZIM_header & header, quint32 articleNumber, string & result,
|
||||
set< quint32 > * loadedArticles = NULL )
|
||||
{
|
||||
result.clear();
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
if( articleNumber >= header.articleCount )
|
||||
|
@ -409,7 +411,6 @@ quint32 readArticle( ZimFile & file, ZIM_header & header, quint32 articleNumber,
|
|||
memcpy( offsets, decompressedData.data() + artEntry.blobNumber * 4, sizeof(offsets) );
|
||||
quint32 size = offsets[ 1 ] - offsets[ 0 ];
|
||||
|
||||
result.clear();
|
||||
result.append( decompressedData, offsets[ 0 ], size );
|
||||
|
||||
return articleNumber;
|
||||
|
@ -496,7 +497,8 @@ private:
|
|||
/// Loads the article.
|
||||
quint32 loadArticle( quint32 address,
|
||||
string & articleText,
|
||||
set< quint32 > * loadedArticles );
|
||||
set< quint32 > * loadedArticles,
|
||||
bool rawText = false );
|
||||
|
||||
string convert( string const & in_data );
|
||||
friend class ZimArticleRequest;
|
||||
|
@ -589,14 +591,16 @@ void ZimDictionary::loadIcon() throw()
|
|||
|
||||
quint32 ZimDictionary::loadArticle( quint32 address,
|
||||
string & articleText,
|
||||
set< quint32 > * loadedArticles )
|
||||
set< quint32 > * loadedArticles,
|
||||
bool rawText )
|
||||
{
|
||||
quint32 ret;
|
||||
{
|
||||
Mutex::Lock _( zimMutex );
|
||||
ret = readArticle( df, zimHeader, address, articleText, loadedArticles );
|
||||
}
|
||||
articleText = convert( articleText );
|
||||
if( !rawText )
|
||||
articleText = convert( articleText );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -808,7 +812,7 @@ void ZimDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
headword.clear();
|
||||
string articleText;
|
||||
|
||||
loadArticle( articleAddress, articleText, 0 );
|
||||
loadArticle( articleAddress, articleText, 0, true );
|
||||
text = Html::unescape( QString::fromUtf8( articleText.data(), articleText.size() ) );
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
|
@ -826,7 +830,7 @@ quint32 ZimDictionary::getArticleText( uint32_t articleAddress, QString & headwo
|
|||
headword.clear();
|
||||
string articleText;
|
||||
|
||||
articleNumber = loadArticle( articleAddress, articleText, loadedArticles );
|
||||
articleNumber = loadArticle( articleAddress, articleText, loadedArticles, true );
|
||||
text = Html::unescape( QString::fromUtf8( articleText.data(), articleText.size() ) );
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
|
|
Loading…
Reference in a new issue