From fc3ea0045e0e41ac9b31a1673eb6d7b4f13762d3 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Sat, 24 Aug 2024 07:45:45 +0800 Subject: [PATCH] opt: remove fulltext unused logic (#1733) * opt: remove fulltext unused logic the firstIteration is not used any more --- src/dict/aard.cc | 6 ++---- src/dict/bgl.cc | 6 ++---- src/dict/dictdfiles.cc | 6 ++---- src/dict/dictionary.hh | 2 +- src/dict/dsl.cc | 6 ++---- src/dict/epwing.cc | 6 ++---- src/dict/gls.cc | 6 ++---- src/dict/mdx.cc | 6 ++---- src/dict/sdict.cc | 6 ++---- src/dict/slob.cc | 6 ++---- src/dict/stardict.cc | 6 ++---- src/dict/xdxf.cc | 6 ++---- src/dict/zim.cc | 7 ++----- src/fulltextsearch.cc | 2 +- 14 files changed, 26 insertions(+), 51 deletions(-) diff --git a/src/dict/aard.cc b/src/dict/aard.cc index 421f9595..466c151c 100644 --- a/src/dict/aard.cc +++ b/src/dict/aard.cc @@ -259,7 +259,7 @@ public: getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -544,7 +544,7 @@ QString const & AardDictionary::getDescription() return dictionaryDescription; } -void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -556,8 +556,6 @@ void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration if ( ensureInitDone().size() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "Aard: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/bgl.cc b/src/dict/bgl.cc index 1435d950..09c52919 100644 --- a/src/dict/bgl.cc +++ b/src/dict/bgl.cc @@ -215,7 +215,7 @@ public: void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -414,7 +414,7 @@ void BglDictionary::getArticleText( uint32_t articleAddress, QString & headword, } } -void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -423,8 +423,6 @@ void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration if ( haveFTSIndex() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "Bgl: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/dictdfiles.cc b/src/dict/dictdfiles.cc index 60012101..169dc6d0 100644 --- a/src/dict/dictdfiles.cc +++ b/src/dict/dictdfiles.cc @@ -136,7 +136,7 @@ public: getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -435,7 +435,7 @@ QString const & DictdDictionary::getDescription() return dictionaryDescription; } -void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -447,8 +447,6 @@ void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteratio if ( ensureInitDone().size() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "DictD: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/dictionary.hh b/src/dict/dictionary.hh index ef2ecdcc..cdb1e65b 100644 --- a/src/dict/dictionary.hh +++ b/src/dict/dictionary.hh @@ -523,7 +523,7 @@ public: } /// Make index for full-text search - virtual void makeFTSIndex( QAtomicInt &, bool ) {} + virtual void makeFTSIndex( QAtomicInt & ) {} /// Set full-text search parameters virtual void setFTSParameters( Config::FullTextSearch const & ) {} diff --git a/src/dict/dsl.cc b/src/dict/dsl.cc index 88ee1d44..ec2137a8 100644 --- a/src/dict/dsl.cc +++ b/src/dict/dsl.cc @@ -229,7 +229,7 @@ public: void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -1072,7 +1072,7 @@ QString DslDictionary::getMainFilename() return getDictionaryFilenames()[ 0 ].c_str(); } -void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) { @@ -1086,8 +1086,6 @@ void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration if ( !ensureInitDone().empty() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "Dsl: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/epwing.cc b/src/dict/epwing.cc index ce3b26c0..98eae640 100644 --- a/src/dict/epwing.cc +++ b/src/dict/epwing.cc @@ -148,7 +148,7 @@ public: getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -425,7 +425,7 @@ QString const & EpwingDictionary::getDescription() return dictionaryDescription; } -void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -435,8 +435,6 @@ void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIterati if ( haveFTSIndex() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "Epwing: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/gls.cc b/src/dict/gls.cc index 03256a0f..c9376c0c 100644 --- a/src/dict/gls.cc +++ b/src/dict/gls.cc @@ -404,7 +404,7 @@ public: void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -546,7 +546,7 @@ QString GlsDictionary::getMainFilename() return getDictionaryFilenames()[ 0 ].c_str(); } -void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -558,8 +558,6 @@ void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration if ( ensureInitDone().size() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "Gls: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/mdx.cc b/src/dict/mdx.cc index 665f3a72..689cae2d 100644 --- a/src/dict/mdx.cc +++ b/src/dict/mdx.cc @@ -254,7 +254,7 @@ public: getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -438,7 +438,7 @@ void MdxDictionary::doDeferredInit() } } -void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -450,8 +450,6 @@ void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration // if( !ensureInitDone().empty() ) // return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "MDict: Building the full-text index for dictionary: %s", getName().c_str() ); diff --git a/src/dict/sdict.cc b/src/dict/sdict.cc index 207ffe23..fc98684f 100644 --- a/src/dict/sdict.cc +++ b/src/dict/sdict.cc @@ -173,7 +173,7 @@ public: getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -379,7 +379,7 @@ void SdictDictionary::loadArticle( uint32_t address, string & articleText ) articleText.append( "" ); } -void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -391,8 +391,6 @@ void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteratio if ( ensureInitDone().size() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "SDict: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/slob.cc b/src/dict/slob.cc index c8e1b164..5f19b564 100644 --- a/src/dict/slob.cc +++ b/src/dict/slob.cc @@ -636,7 +636,7 @@ public: quint64 getArticlePos( uint32_t articleNumber ); - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -891,7 +891,7 @@ quint64 SlobDictionary::getArticlePos( uint32_t articleNumber ) return ( ( (quint64)( entry.binIndex ) ) << 32 ) | entry.itemIndex; } -void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -903,8 +903,6 @@ void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration if ( !ensureInitDone().empty() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "Slob: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/stardict.cc b/src/dict/stardict.cc index c5096aaa..b9346ca3 100644 --- a/src/dict/stardict.cc +++ b/src/dict/stardict.cc @@ -196,7 +196,7 @@ public: getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -1085,7 +1085,7 @@ QString StardictDictionary::getMainFilename() return getDictionaryFilenames()[ 0 ].c_str(); } -void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -1097,8 +1097,6 @@ void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstItera if ( ensureInitDone().size() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "Stardict: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/xdxf.cc b/src/dict/xdxf.cc index bda3fd85..bdb1f9b1 100644 --- a/src/dict/xdxf.cc +++ b/src/dict/xdxf.cc @@ -196,7 +196,7 @@ public: getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -369,7 +369,7 @@ QString XdxfDictionary::getMainFilename() return getDictionaryFilenames()[ 0 ].c_str(); } -void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -381,8 +381,6 @@ void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration if ( ensureInitDone().size() ) return; - if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch ) - return; gdDebug( "Xdxf: Building the full-text index for dictionary: %s\n", getName().c_str() ); diff --git a/src/dict/zim.cc b/src/dict/zim.cc index 61a13ab4..78a05048 100644 --- a/src/dict/zim.cc +++ b/src/dict/zim.cc @@ -217,7 +217,7 @@ public: getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; - void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; + void makeFTSIndex( QAtomicInt & isCancelled ) override; void setFTSParameters( Config::FullTextSearch const & fts ) override { @@ -480,7 +480,7 @@ QString const & ZimDictionary::getDescription() return dictionaryDescription; } -void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) +void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled ) { if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) @@ -492,9 +492,6 @@ void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration if ( !ensureInitDone().empty() ) return; - if ( firstIteration ) - return; - gdDebug( "Zim: Building the full-text index for dictionary: %s\n", getName().c_str() ); try { FtsHelpers::makeFTSIndex( this, isCancelled ); diff --git a/src/fulltextsearch.cc b/src/fulltextsearch.cc index 34a9c80f..efcee7cd 100644 --- a/src/fulltextsearch.cc +++ b/src/fulltextsearch.cc @@ -34,7 +34,7 @@ void Indexing::run() const QString & dictionaryName = QString::fromUtf8( dictionary->getName().c_str() ); qDebug() << "[FULLTEXT] checking fts for the dictionary:" << dictionaryName; emit sendNowIndexingName( dictionaryName ); - dictionary->makeFTSIndex( isCancelled, false ); + dictionary->makeFTSIndex( isCancelled ); } ); synchronizer.addFuture( f ); }