From 9ecc10ed50ff2034a16358e7d5be404652391474 Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Wed, 16 Feb 2022 21:47:03 +0800 Subject: [PATCH] performance: Prefer prefix ++/-- operators for non-primitive types. more detail check https://hownot2code.com/2016/06/30/use-a-prefix-increment-operator-i-in-iterators-instead-of-a-postfix-i-operator/ --- mainwindow.cc | 2 +- mdictparser.cc | 2 +- mdx.cc | 12 ++++++------ processwrapper.cc | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mainwindow.cc b/mainwindow.cc index e13389e4..e21412d8 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -3566,7 +3566,7 @@ void MainWindow::on_saveArticle_triggered() // Pull and save resources to files for ( vector< pair< QUrl, QString > >::const_iterator i = downloadResources.begin(); - i != downloadResources.end(); i++ ) + i != downloadResources.end(); ++i ) { ResourceToSaveHandler * handler = view->saveResource( i->first, i->second ); if( !handler->isEmpty() ) diff --git a/mdictparser.cc b/mdictparser.cc index ca0ae455..e121ee07 100644 --- a/mdictparser.cc +++ b/mdictparser.cc @@ -165,7 +165,7 @@ bool MdictParser::readNextHeadWordIndex( MdictParser::HeadWordIndex & headWordIn return false; headWordIndex = splitHeadWordBlock( decompressed ); - headWordBlockInfosIter_++; + ++headWordBlockInfosIter_; return true; } diff --git a/mdx.cc b/mdx.cc index 3545210f..816d94bd 100644 --- a/mdx.cc +++ b/mdx.cc @@ -848,7 +848,7 @@ void MddResourceRequest::run() catch ( File::exCantOpen & ) { for ( vector< sptr< IndexedMdd > >::const_iterator i = dict.mddResources.begin(); - i != dict.mddResources.end(); i++ ) + i != dict.mddResources.end(); ++i ) { sptr< IndexedMdd > mddResource = *i; if ( mddResource->loadFile( resourceName, data ) ) @@ -1272,7 +1272,7 @@ QString MdxDictionary::getCachedFileName( QString filename ) catch ( File::exCantOpen & ) { for ( vector< sptr< IndexedMdd > >::const_iterator i = mddResources.begin(); - i != mddResources.end(); i++ ) + i != mddResources.end(); ++i ) { sptr< IndexedMdd > mddResource = *i; if ( mddResource->loadFile( resourceName, data ) ) @@ -1447,7 +1447,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f { vector< sptr< Dictionary::Class > > dictionaries; - for ( vector< string >::const_iterator i = fileNames.begin(); i != fileNames.end(); i++ ) + 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 @@ -1477,7 +1477,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f initializing.indexingDictionary( title ); for ( vector< string >::const_iterator mddIter = dictFiles.begin() + 1; - mddIter != dictFiles.end(); mddIter++ ) + mddIter != dictFiles.end(); ++mddIter ) { if ( File::exists( *mddIter ) ) { @@ -1576,7 +1576,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f idxHeader.styleSheetCount = styleSheets.size(); for ( MdictParser::StyleSheets::const_iterator iter = styleSheets.begin(); - iter != styleSheets.end(); iter++ ) + iter != styleSheets.end(); ++iter ) { string styleBegin( iter->second.first.toUtf8().constData() ); string styleEnd( iter->second.second.toUtf8().constData() ); @@ -1607,7 +1607,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f // Build index info for each mdd file vector< IndexInfo > mddIndexInfos; for ( vector< sptr< IndexedWords > >::const_iterator mddIndexIter = mddIndices.begin(); - mddIndexIter != mddIndices.end(); mddIndexIter++ ) + mddIndexIter != mddIndices.end(); ++mddIndexIter ) { IndexInfo resourceIdxInfo = BtreeIndexing::buildIndex( *( *mddIndexIter ), idx ); mddIndexInfos.push_back( resourceIdxInfo ); diff --git a/processwrapper.cc b/processwrapper.cc index 9d525830..0359e963 100644 --- a/processwrapper.cc +++ b/processwrapper.cc @@ -112,7 +112,7 @@ unsigned int ProcessWrapper::findProcess(const char *name, unsigned int pid_skip QDir pd("/proc"); QFileInfoList list = pd.entryInfoList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); QFileInfoList::iterator it, it_end = list.end(); - for (it = list.begin(); it != it_end; it++) + for (it = list.begin(); it != it_end; ++it) { const QFileInfo &fi = *it; if (fi.baseName().at(0).isDigit()) {