mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Merge pull request #1029 from xiaoyifang/opt/load-slow
opt: optimize the startup speed
This commit is contained in:
commit
f7e43479d6
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue