[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [konsole] src: A loop can run zero times without another check.
From: Andreas Hartmetz <ahartmetz () gmail ! com>
Date: 2016-10-08 19:41:09
Message-ID: E1bsxUb-0004Wq-0L () code ! kde ! org
[Download RAW message or body]
Git commit 35fdfb2fcbdc7aca64639cf18e9ac40a42d59873 by Andreas Hartmetz.
Committed on 08/10/2016 at 18:32.
Pushed by ahartmetz into branch 'master'.
A loop can run zero times without another check.
While at it, constify and adjust coding style.
M +11 -12 src/SessionManager.cpp
http://commits.kde.org/konsole/35fdfb2fcbdc7aca64639cf18e9ac40a42d59873
diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp
index b76b1cf..2cb1bdb 100644
--- a/src/SessionManager.cpp
+++ b/src/SessionManager.cpp
@@ -295,21 +295,20 @@ int SessionManager::getRestoreId(Session* session)
void SessionManager::restoreSessions(KConfig* config)
{
KConfigGroup group(config, "Number");
- int sessions;
+ const int sessions = group.readEntry("NumberOfSessions", 0);
// Any sessions saved?
- if ((sessions = group.readEntry("NumberOfSessions", 0)) > 0) {
- for (int n = 1; n <= sessions; n++) {
- QString name = QLatin1String("Session") + QString::number(n);
- KConfigGroup sessionGroup(config, name);
-
- QString profile = sessionGroup.readPathEntry("Profile", QString());
- Profile::Ptr ptr = ProfileManager::instance()->defaultProfile();
- if (!profile.isEmpty()) ptr = ProfileManager::instance()->loadProfile(profile);
-
- Session* session = createSession(ptr);
- session->restoreSession(sessionGroup);
+ for (int n = 1; n <= sessions; n++) {
+ const QString name = QLatin1String("Session") + QString::number(n);
+ KConfigGroup sessionGroup(config, name);
+
+ const QString profile = sessionGroup.readPathEntry("Profile", QString());
+ Profile::Ptr ptr = ProfileManager::instance()->defaultProfile();
+ if (!profile.isEmpty()) {
+ ptr = ProfileManager::instance()->loadProfile(profile);
}
+ Session* session = createSession(ptr);
+ session->restoreSession(sessionGroup);
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic