[PATCH] Prefix incrementing of iterators is more preferable than postfix one.

Dmitri Paduchikh dpaduchikh на gmail.com
Вс Фев 24 12:25:45 MSK 2013


---
 daemon/config_file/ConfigFile.cpp |  2 +-
 daemon/core/MainLoop.cpp          |  2 +-
 daemon/core/OutputSet.cpp         |  2 +-
 daemon/langs/EngLang.cpp          |  4 ++--
 daemon/langs/RusLang.cpp          |  2 +-
 daemon/main/configuration.cpp     | 16 +++++++++-------
 daemon/main/main.cpp              | 23 ++++++++++++++---------
 emacspeak/LineParser.cpp          |  2 +-
 8 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/daemon/config_file/ConfigFile.cpp b/daemon/config_file/ConfigFile.cpp
index 25acf0b..9375fc6 100644
--- a/daemon/config_file/ConfigFile.cpp
+++ b/daemon/config_file/ConfigFile.cpp
@@ -315,7 +315,7 @@ int ConfigFile::params(const std::string& section, const std::string& param) con
 
 void ConfigFile::checkParamsInSection(const ConfigFileSection& section) const
 {
-  for(ConfigFileSection::const_iterator it = section.begin();it != section.end();it++)
+  for (ConfigFileSection::const_iterator it = section.begin(); it != section.end(); ++it)
     {
       int requiredType = params(section.getName(), it->first);
       const std::string& value = it->second;
diff --git a/daemon/core/MainLoop.cpp b/daemon/core/MainLoop.cpp
index 20a086c..397cff2 100644
--- a/daemon/core/MainLoop.cpp
+++ b/daemon/core/MainLoop.cpp
@@ -130,7 +130,7 @@ void MainLoop::run(const SocketList& sockets, sigset_t* sigMask)
 	  m_clientDataHandler.processClientData(**clientIt, data);
 	} // for (clients);
     } // while(!m_terminationFlag);
-  for(ClientList::iterator it = m_connectedClients.begin();it != m_connectedClients.end();it++)
+  for (ClientList::iterator it = m_connectedClients.begin(); it != m_connectedClients.end(); ++it)
     delete *it;
   m_connectedClients.clear();
 }
diff --git a/daemon/core/OutputSet.cpp b/daemon/core/OutputSet.cpp
index f0a0bdf..56db965 100644
--- a/daemon/core/OutputSet.cpp
+++ b/daemon/core/OutputSet.cpp
@@ -23,7 +23,7 @@ void OutputSet::reinit(const OutputList& outputs)
     return;
   m_outputs.resize(outputs.size());
   OutputVector::size_type index = 0;
-  for(OutputList::const_iterator it = outputs.begin();it != outputs.end();it++)
+  for (OutputList::const_iterator it = outputs.begin(); it != outputs.end(); ++it)
     {
       assert(index < m_outputs.size());
       m_outputs[index] = *it;
diff --git a/daemon/langs/EngLang.cpp b/daemon/langs/EngLang.cpp
index fcd72c8..7129a81 100644
--- a/daemon/langs/EngLang.cpp
+++ b/daemon/langs/EngLang.cpp
@@ -301,7 +301,7 @@ std::wstring EngLang::separate(const std::wstring& text) const
 
 bool EngLang::checkCapList(const std::wstring& str, std::wstring::size_type pos, std::wstring& result) const
 {
-  for(CapItemList::const_iterator i = m_capItems.begin();i != m_capItems.end();i++)
+  for (CapItemList::const_iterator i = m_capItems.begin(); i != m_capItems.end(); ++i)
     {
       std::wstring s = toLower(i->str);
       if (str.length() < s.length() + pos)//must be (str.length() - pos < s.length()), but it can cause sign problems;
@@ -360,7 +360,7 @@ void EngLang::loadCaps(const std::string& fileName)
   text = cutComments(text);
   StringList lines;
   splitTextFileLines(text, lines, 1, 1);// 1 and 1 means trim lines and skip empty;
-  for(StringList::const_iterator it = lines.begin();it != lines.end();it++)
+  for (StringList::const_iterator it = lines.begin(); it != lines.end(); ++it)
     {
       const std::string& s = *it;
       std::string::size_type l, r;
diff --git a/daemon/langs/RusLang.cpp b/daemon/langs/RusLang.cpp
index 9be882d..0219156 100644
--- a/daemon/langs/RusLang.cpp
+++ b/daemon/langs/RusLang.cpp
@@ -42,7 +42,7 @@ void RusLang::load(const std::string& fileName)
   fileText = cutComments(fileText);
   StringList lines;
   splitTextFileLines(fileText, lines, 1, 1);//1 and 1 means trim lines and skip empty;
-  for(StringList::const_iterator it = lines.begin();it != lines.end();it++)
+  for (StringList::const_iterator it = lines.begin(); it != lines.end(); ++it)
     {
       std::string t = trim(::toLower(getDelimitedSubStr(*it, 0, ':')));
       if (t.empty())
diff --git a/daemon/main/configuration.cpp b/daemon/main/configuration.cpp
index b33028c..6da25a8 100644
--- a/daemon/main/configuration.cpp
+++ b/daemon/main/configuration.cpp
@@ -237,7 +237,7 @@ static void processFamiliesConfiguration(const LangManager& langs, const Voicema
   if (config.hasSection("families"))
     {
       const ConfigFileSection& sec = config.findSection("families");
-      for(ConfigFileSection::const_iterator it = sec.begin();it != sec.end();it++)
+      for (ConfigFileSection::const_iterator it = sec.begin(); it != sec.end(); ++it)
 	{
 	  const std::string name = trim(toLower(it->first));
 	  const std::string value = trim(toLower(it->second));
@@ -278,7 +278,7 @@ static void processFamiliesConfiguration(const LangManager& langs, const Voicema
   ////Checking if we have enough information to select default family;
   StringList supportedLanguages;
   langs.getSupportedLanguageNames(supportedLanguages);
-  for(StringList::const_iterator it = supportedLanguages.begin();it != supportedLanguages.end();it++)
+  for (StringList::const_iterator it = supportedLanguages.begin(); it != supportedLanguages.end(); ++it)
     {
       const LangId langId = langs.getLangId(*it);
       assert(langId != LANG_ID_NONE);
@@ -354,7 +354,7 @@ static void processCharactersSection(const LangManager& langs, const VoicemanCon
   if (config.hasSection("characters"))
     {
       const ConfigFileSection& sec = config.findSection("characters");
-      for(ConfigFileSection::const_iterator it = sec.begin();it != sec.end();it++)
+      for (ConfigFileSection::const_iterator it = sec.begin(); it != sec.end(); ++it)
 	{
 	  const std::string langName = trim(toLower(it->first));
 	  LangId langId = LANG_ID_NONE;
@@ -508,7 +508,7 @@ static void printOutputsConfiguration(const LangManager& langs, const Configurat
       if (!o.capList.empty())
 	{
 	  std::cout << "cap list = ";
-	  for(WCharToWStringMap::const_iterator it = o.capList.begin();it != o.capList.end();it++)
+	  for (WCharToWStringMap::const_iterator it = o.capList.begin(); it != o.capList.end(); ++it)
 	    {
 	      std::wstring s1;
 	      s1 += it->first;
@@ -581,7 +581,7 @@ void printConfiguration(const LangManager& langs, const Configuration& c)
     {
       std::cout << std::endl;
       std::cout << "Characters map:" << std::endl;
-      for(LangIdToWStringMap::const_iterator it = c.characters.begin();it != c.characters.end();it++)
+      for (LangIdToWStringMap::const_iterator it = c.characters.begin(); it != c.characters.end(); ++it)
 	std::cout << (it->first != LANG_ID_NONE?langs.getLangName(it->first):"default") << " = " << it->second << std::endl;
     }
   printOutputsConfiguration(langs, c);
@@ -589,14 +589,16 @@ void printConfiguration(const LangManager& langs, const Configuration& c)
     {
       std::cout << std::endl;
       std::cout << "Default families for languages:" << std::endl;
-      for(LangIdToStringMap::const_iterator it = c.defaultFamilies.begin();it != c.defaultFamilies.end();it++)
+      for (LangIdToStringMap::const_iterator it = c.defaultFamilies.begin();
+	   it != c.defaultFamilies.end(); ++it)
 	std::cout << langs.getLangName(it->first) << " = " << it->second << std::endl;
     } //default families;
   if (!c.characters.empty())
     {
       std::cout << std::endl;
       std::cout << "Characters map:" << std::endl;
-	for(LangIdToWStringMap::const_iterator it = c.characters.begin();it != c.characters.end();it++)
+	for (LangIdToWStringMap::const_iterator it = c.characters.begin();
+	     it != c.characters.end(); ++it)
 	  std::cout << (it->first != LANG_ID_NONE?langs.getLangName(it->first):"default") << " = " << it->second << std::endl;
     } //characters;
 }
diff --git a/daemon/main/main.cpp b/daemon/main/main.cpp
index 3f97afc..fa9f568 100644
--- a/daemon/main/main.cpp
+++ b/daemon/main/main.cpp
@@ -101,7 +101,8 @@ void fillOutputListByConfiguration(const OutputConfigurationVector& outputConfig
 	      o.addReplacement(readUTF8(fromString), readUTF8(toString));
 	    } //for(lines in replacements file);
 	} //replacements reading;
-      for(WCharToWStringMap::const_iterator it = oc.capList.begin();it != oc.capList.end();it++)
+      for (WCharToWStringMap::const_iterator it = oc.capList.begin();
+	   it != oc.capList.end(); ++it)
 	o.addCapMapItem(it->first, it->second);
       logMsg(LOG_DEBUG, "Adding output \'%s\' to output set", outputConfigurations[i].name.c_str());
       outputList.push_back(o);
@@ -190,7 +191,8 @@ public:
     //OK, now we have the set of splitted items, but output information is omitted in it, only language specifications;
     TextItemList preparedTextItems;
     assignOutput(client, textItemList, preparedTextItems);
-    for(TextItemList::const_iterator it = preparedTextItems.begin();it != preparedTextItems.end();it++)
+    for (TextItemList::const_iterator it = preparedTextItems.begin();
+	 it != preparedTextItems.end(); ++it)
       m_executorInterface.sayOrEnqueue(*it);
   }
 
@@ -216,7 +218,8 @@ public:
     //OK, now we have the set of splitted items, but output information is omitted in it, only language specifications;
     TextItemList preparedTextItems;
     assignOutput(client, textItemList, preparedTextItems);
-    for(TextItemList::const_iterator it = preparedTextItems.begin();it != preparedTextItems.end();it++)
+    for (TextItemList::const_iterator it = preparedTextItems.begin();
+	 it != preparedTextItems.end(); ++it)
       m_executorInterface.sayOrEnqueue(*it);
   }
 
@@ -346,7 +349,8 @@ public:
     if (langId == LANG_ID_NONE)
       {
 	//Using m_defaultFamilies map to enumerate all available languages;
-	for(LangIdToStringMap::const_iterator it = m_defaultFamilies.begin();it != m_defaultFamilies.end();it++)
+	for (LangIdToStringMap::const_iterator it = m_defaultFamilies.begin();
+	     it != m_defaultFamilies.end(); ++it)
 	  {
 	    if (!m_outputSet.isValidFamilyName(it->first, family))
 	      continue;
@@ -374,7 +378,7 @@ private:
   void assignOutput(const Client& client, TextItemList& textItemList, TextItemList& preparedItems) const
   {
     preparedItems.clear();
-    for(TextItemList::iterator it = textItemList.begin();it != textItemList.end();it++)
+    for (TextItemList::iterator it = textItemList.begin(); it != textItemList.end(); ++it)
       {
 	const TextItem& ti = *it;
 	//Now we must find  proper output to process;
@@ -425,7 +429,7 @@ private:
     //Using only really required languages;
     for(OutputConfigurationVector::size_type i = 0;i < c.outputs.size();i++)
       langIdSet.insert(c.outputs[i].langId);
-    for(LangIdSet::const_iterator it = langIdSet.begin();it != langIdSet.end();it++)
+    for (LangIdSet::const_iterator it = langIdSet.begin(); it != langIdSet.end(); ++it)
       {
 	logMsg(LOG_DEBUG, "Adding \'%s\' language support to text processor \'%s\'", langManager.getLangName(*it).c_str(), name.c_str());
 	const Lang* lang = langManager.getLangById(*it);
@@ -506,7 +510,8 @@ private:
 
   void destroyAllTextProcessors()
   {
-    for(StringToTextProcMap::iterator it = m_textProcessors.begin();it != m_textProcessors.end();it++)
+    for (StringToTextProcMap::iterator it = m_textProcessors.begin();
+	 it != m_textProcessors.end(); ++it)
       delete it->second;
     m_textProcessors.clear();
   }
@@ -586,7 +591,7 @@ public:
 	m_outputSet.reinit(outputList);
 	m_protocolHandler.reinit(c);
 	logMsg(LOG_DEBUG, "resetting families preferences for %u clients", m_clients.size());
-	for(ClientList::iterator it = m_clients.begin();it != m_clients.end();it++)
+	for (ClientList::iterator it = m_clients.begin(); it != m_clients.end(); ++it)
 	  (*it)->selectedFamilies.clear();
 	logMsg(LOG_INFO, "New configuration was successfully reloaded!");
       }
@@ -791,7 +796,7 @@ private:
 
   void closeAllConnections()
   {
-    for (ClientList::iterator it = m_clients.begin();it != m_clients.end();it++)
+    for (ClientList::iterator it = m_clients.begin(); it != m_clients.end(); ++it)
       delete *it;//sockets will be closed automatically in destructor;
     m_clients.clear();
   }
diff --git a/emacspeak/LineParser.cpp b/emacspeak/LineParser.cpp
index c6b6aaf..9dd2ed1 100644
--- a/emacspeak/LineParser.cpp
+++ b/emacspeak/LineParser.cpp
@@ -142,7 +142,7 @@ void LineParser::q(const std::string& s)
 
 void LineParser::d()
 {
-  for(TextItemList::const_iterator it = m_items.begin();it != m_items.end();it++)
+  for (TextItemList::const_iterator it = m_items.begin(); it != m_items.end(); ++it)
     {
       if (m_pitchShift >= 0 || it->pitch > (size_t)(-1 * m_pitchShift))
 	m_connection.pitch(it->pitch + m_pitchShift); else
-- 
1.8.1.4


--=-=-=--


Подробная информация о списке рассылки Homeros