From 0b5f64d2912691155cc3f4f13753f6049e3d9a5a Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Wed, 27 Mar 2024 16:30:35 +0800 Subject: [PATCH] opt: unify dictionaryid generation --- src/dict/dictionary.cc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/dict/dictionary.cc b/src/dict/dictionary.cc index a7ca9f8b..1e90a280 100644 --- a/src/dict/dictionary.cc +++ b/src/dict/dictionary.cc @@ -509,26 +509,16 @@ string makeDictionaryId( vector< string > const & dictionaryFiles ) noexcept { std::vector< string > sortedList; - if ( Config::isPortableVersion() ) { - // For portable version, we use relative paths + + // use filename to unify the calculation step sortedList.reserve( dictionaryFiles.size() ); - const QDir dictionariesDir( Config::getPortableVersionDictionaryDir() ); for ( const auto & full : dictionaryFiles ) { QFileInfo fileInfo( QString::fromStdString( full ) ); - - if ( fileInfo.isAbsolute() ) - sortedList.push_back( dictionariesDir.relativeFilePath( fileInfo.filePath() ).toStdString() ); - else { - // Well, it's relative. We don't technically support those, but - // what the heck - sortedList.push_back( full ); - } + sortedList.push_back( fileInfo.fileName().toStdString() ); } - } - else - sortedList = dictionaryFiles; + std::sort( sortedList.begin(), sortedList.end() );