Revert "optimize: for loop optimize"

This reverts commit 0e238c26fb.
This commit is contained in:
xiaoyifang 2022-04-13 23:29:36 +08:00
parent 2e6cf12d78
commit 0759259b76
3 changed files with 10 additions and 16 deletions

View file

@ -131,14 +131,6 @@ void LoadDictionaries::handlePath( Config::Path const & path )
allFiles.push_back( FsEncoding::encode( QDir::toNativeSeparators( fullName ) ) );
}
{
vector< sptr< Dictionary::Class > > mdxDictionaries =
Mdx::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), mdxDictionaries.begin(),
mdxDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > bglDictionaries =
Bgl::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
@ -207,6 +199,13 @@ void LoadDictionaries::handlePath( Config::Path const & path )
dictionaries.insert( dictionaries.end(), zipSoundsDictionaries.begin(),
zipSoundsDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > mdxDictionaries =
Mdx::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), mdxDictionaries.begin(),
mdxDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > glsDictionaries =
Gls::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );

9
mdx.cc
View file

@ -1455,21 +1455,18 @@ static void findResourceFiles( string const & mdx, vector< string > & dictFiles
}
}
vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > & fileNames,
vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames,
string const & indicesDir,
Dictionary::Initializing & initializing )
{
vector< sptr< Dictionary::Class > > dictionaries;
for ( vector< string >::iterator i = fileNames.begin(); i != fileNames.end(); )
for ( vector< string >::const_iterator i = fileNames.begin(); i != fileNames.end(); ++i )
{
// Skip files with the extensions different to .mdx to speed up the
// scanning
if ( i->size() < 4 || strcasecmp( i->c_str() + ( i->size() - 4 ), ".mdx" ) != 0 )
{
i++;
continue;
}
vector< string > dictFiles( 1, *i );
findResourceFiles( *i, dictFiles );
@ -1656,8 +1653,6 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > & fileNam
}
dictionaries.push_back( new MdxDictionary( dictId, indexFile, dictFiles ) );
i=fileNames.erase(i);
}
return dictionaries;

2
mdx.hh
View file

@ -12,7 +12,7 @@ namespace Mdx
using std::vector;
using std::string;
vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > & fileNames,
vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames,
string const & indicesDir,
Dictionary::Initializing & ) ;