Merge pull request #1029 from xiaoyifang/opt/load-slow

opt: optimize the startup speed
This commit is contained in:
xiaoyifang 2023-07-30 16:50:23 +08:00 committed by GitHub
commit f7e43479d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -113,6 +113,23 @@ void LoadDictionaries::run()
dictionaries.insert( dictionaries.end(), hunspellDictionaries.begin(), hunspellDictionaries.end() );
}
//handle the custom dictionary name&fts option
for ( const auto & dict : dictionaries ) {
auto baseDir = dict->getContainingFolder();
if ( baseDir.isEmpty() )
continue;
auto filePath = Utils::Path::combine( baseDir, "metadata.toml" );
auto dictMetaData = Metadata::load( filePath.toStdString() );
if ( dictMetaData && dictMetaData->name ) {
dict->setName( dictMetaData->name.value() );
}
if ( dictMetaData && dictMetaData->fullindex ) {
dict->setFtsEnable( dictMetaData->fullindex.value() );
}
}
exceptionText.clear();
}
catch ( std::exception & e ) {
@ -166,23 +183,6 @@ void LoadDictionaries::handlePath( Config::Path const & path )
#ifndef NO_EPWING_SUPPORT
addDicts( Epwing::makeDictionaries( allFiles, Config::getIndexDir().toStdString(), *this ) );
#endif
//handle the custom dictionary name
for ( const auto & dict : dictionaries ) {
auto baseDir = dict->getContainingFolder();
if ( baseDir.isEmpty() )
continue;
auto filePath = Utils::Path::combine( baseDir, "metadata.toml" );
auto dictMetaData = Metadata::load( filePath.toStdString() );
if ( dictMetaData && dictMetaData->name ) {
dict->setName( dictMetaData->name.value() );
}
if ( dictMetaData && dictMetaData->fullindex ) {
dict->setFtsEnable( dictMetaData->fullindex.value() );
}
}
}
void LoadDictionaries::indexingDictionary( string const & dictionaryName ) noexcept