From 048ce47008bc4cf88e78c0a2950fc607c80ddf64 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Mon, 4 Aug 2025 10:16:28 -0400 Subject: [PATCH] refactor: ServerConfig: used ranged loop to process neighbours --- src/lib/gui/ServerConfig.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/gui/ServerConfig.cpp b/src/lib/gui/ServerConfig.cpp index 8d65f3a64..e666f0d59 100644 --- a/src/lib/gui/ServerConfig.cpp +++ b/src/lib/gui/ServerConfig.cpp @@ -246,15 +246,18 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config) outStream << "section: links" << Qt::endl; - for (int i = 0; i < config.screens().size(); i++) { - if (!config.screens()[i].isNull()) { - outStream << "\t" << config.screens()[i].name() << ":" << Qt::endl; - for (unsigned int j = 0; j < std::size(neighbourDirs); j++) { - int idx = config.adjacentScreenIndex(i, neighbourDirs[j].x, neighbourDirs[j].y); - if (idx != -1 && !config.screens()[idx].isNull()) - outStream << "\t\t" << neighbourDirs[j].name << " = " << config.screens()[idx].name() << Qt::endl; - } + for (int i = 0; const auto &screen : config.screens()) { + if (screen.isNull()) { + i++; + continue; } + outStream << "\t" << screen.name() << ":\n"; + for (const auto &neighbour : std::as_const(neighbourDirs)) { + int idx = config.adjacentScreenIndex(i, neighbour.x, neighbour.y); + if (idx != -1 && !config.screens()[idx].isNull()) + outStream << "\t\t" << neighbour.name << " = " << config.screens()[idx].name() << Qt::endl; + } + i++; } outStream << "end" << Qt::endl << Qt::endl;