A loop can run zero times without another check.

While at it, constify and adjust coding style.
This commit is contained in:
Andreas Hartmetz
2016-10-08 20:27:53 +02:00
parent e51946f9e8
commit 35fdfb2fcb

View File

@@ -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);
for (int n = 1; n <= sessions; n++) {
const 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);
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);
}
}