Use c++11 auto keyword
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Thu, 28 Jan 2016 17:56:14 +0000 (18:56 +0100)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Thu, 28 Jan 2016 17:56:14 +0000 (18:56 +0100)
src/kernel/kernel.cpp
src/kernel/options.cpp
src/lgconfig/lgconfig.cpp

index c6a9d1795d252fd286c8ca2266cb406fa141bf01..27ba55f5e6dcf8d7164a657429cf489aa7bcec0e 100644 (file)
@@ -851,9 +851,9 @@ InterpEntry *QKernel::findINTbySocket(int _id)
 {
        InterpEntry *pom = NULL;
        
-       for (int i = 0; i < Interpreters.size(); i++) {
-               if (Interpreters.at(i)->sock == _id) {
-                       pom = Interpreters.at(i);
+       for (auto interpreter : Interpreters) {
+               if (interpreter->sock == _id) {
+                       pom = interpreter;
                        break;
                }
        }
@@ -870,9 +870,9 @@ InterpEntry *QKernel::findINTbyID(int _id)
 {
        InterpEntry *pom = NULL;
        
-       for (int i = 0; i < Interpreters.size(); i++) {
-               if (Interpreters.at(i)->ID == _id) {
-                       pom = Interpreters.at(i);
+       for (auto interpreter : Interpreters) {
+               if (interpreter->ID == _id) {
+                       pom = interpreter;
                        break;
                }
        }
index 5dca8392a0e7ad7504cbc9812f749a5807149a3a..5830ca02b94c05d59802f75ac5a6ba0124453799 100644 (file)
@@ -84,9 +84,8 @@ void OptionsDialog::loadConfig(const char * fname)
                break;
        }
 
-       std::vector<std::string> hosts = config.getHosts();
-       for (unsigned int i = 0; i < hosts.size(); i++) {
-               connections->addItem(hosts[i].c_str());
+       for (auto host : config.getHosts()) {
+               connections->addItem(host.c_str());
        }
 
        programsDirectory->setText(config.getProgramDir());
index 58872ca4c0d5e8f2fdec39e213acc758abb1263d..7c7fcb2ef49ebf1a7fc6253e091a3086bd1c7fc6 100644 (file)
@@ -235,7 +235,7 @@ void QInstall::SetOptions()
        QLabel *tmpQLabel;
        QPushButton *addbtn, *delbtn, *okbtn, *cancelbtn;
        VLPEntry *pom;
-       int i, j;
+       int i;
        char pomstr[255];
 
        //dlg.setStyle(WindowsStyle);
@@ -274,7 +274,7 @@ void QInstall::SetOptions()
                        
                        while (nodesIterator.hasNext()) {
                                pom = nodesIterator.next();
-                               j = Nodes.indexOf(pom);
+                               i = Nodes.indexOf(pom);
                                sprintf(pomstr, "%s.cfg", pom->addr);
 
                                config_t cfg;
@@ -308,13 +308,13 @@ void QInstall::SetOptions()
                                        }
                                        config_setting_set_string(setting, "explicit");
                                }
-                               for (i = 0; i < Nodes.count(); i++) {
-                                       if (pom != Nodes.at(i)) {
+                               for (auto node : Nodes) {
+                                       if (pom != node) {
                                                setting = config_setting_get_member(root, "host");
                                                if (!setting) {
                                                        setting = config_setting_add(root, "host", CONFIG_TYPE_STRING);
                                                }
-                                               config_setting_set_string(setting, Nodes.at(i)->addr);
+                                               config_setting_set_string(setting, node->addr);
                                        }
                                }
 
@@ -323,7 +323,7 @@ void QInstall::SetOptions()
                                }
                                config_destroy(&cfg);
 
-                               pom = Nodes.at(j);
+                               pom = Nodes.at(i);
                        }
                }
        }