From: Rafał Długołęcki Date: Thu, 28 Jan 2016 17:56:14 +0000 (+0100) Subject: Use c++11 auto keyword X-Git-Tag: 3.4-b1~32 X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=a65ea8a9671bc17933d43714eb108ce950606209;p=vlp.git Use c++11 auto keyword --- diff --git a/src/kernel/kernel.cpp b/src/kernel/kernel.cpp index c6a9d17..27ba55f 100644 --- a/src/kernel/kernel.cpp +++ b/src/kernel/kernel.cpp @@ -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; } } diff --git a/src/kernel/options.cpp b/src/kernel/options.cpp index 5dca839..5830ca0 100644 --- a/src/kernel/options.cpp +++ b/src/kernel/options.cpp @@ -84,9 +84,8 @@ void OptionsDialog::loadConfig(const char * fname) break; } - std::vector 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()); diff --git a/src/lgconfig/lgconfig.cpp b/src/lgconfig/lgconfig.cpp index 58872ca..7c7fcb2 100644 --- a/src/lgconfig/lgconfig.cpp +++ b/src/lgconfig/lgconfig.cpp @@ -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); } } }