opt: unify dictionaryid generation

This commit is contained in:
xiaoyifang 2024-03-27 16:30:35 +08:00
parent f91100ca9a
commit 0b5f64d291

View file

@ -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 ) );
sortedList.push_back( fileInfo.fileName().toStdString() );
}
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 );
}
}
}
else
sortedList = dictionaryFiles;
std::sort( sortedList.begin(), sortedList.end() );