summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Hartmetz <ahartmetz@gmail.com>2016-10-08 18:27:53 (GMT)
committerAndreas Hartmetz <ahartmetz@gmail.com>2016-10-08 18:32:22 (GMT)
commit35fdfb2fcbdc7aca64639cf18e9ac40a42d59873 (patch)
tree28cc22e170b73aba9ec62ffe66cb6ce6460ad718
parente51946f9e8dcc840c2e60750adfe9f859c93c38f (diff)
A loop can run zero times without another check.
While at it, constify and adjust coding style.
-rw-r--r--src/SessionManager.cpp23
1 files changed, 11 insertions, 12 deletions
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);
}
}