Commit 90c81d0e authored by Kurt Hindenburg's avatar Kurt Hindenburg
Browse files

Simpify return after else statements

parent 9a80c74b
......@@ -550,9 +550,8 @@ Profile::Ptr Application::processProfileChangeArgs(Profile::Ptr baseProfile)
if (shouldUseNewProfile) {
return newProfile;
} else {
return baseProfile;
}
return baseProfile;
}
void Application::startBackgroundMode(MainWindow *window)
......
......@@ -181,10 +181,9 @@ bool ColorSchemeManager::deleteColorScheme(const QString &name)
if (QFile::remove(path)) {
delete _colorSchemes.take(name);
return true;
} else {
qCDebug(KonsoleDebug)<<"Failed to remove color scheme -"<<path;
return false;
}
}
qCDebug(KonsoleDebug)<<"Failed to remove color scheme -"<<path;
return false;
}
const ColorScheme *ColorSchemeManager::findColorScheme(const QString &name)
......@@ -203,17 +202,16 @@ const ColorScheme *ColorSchemeManager::findColorScheme(const QString &name)
if (_colorSchemes.contains(name)) {
return _colorSchemes[name];
} else {
// look for this color scheme
QString path = findColorSchemePath(name);
if (!path.isEmpty() && loadColorScheme(path)) {
return findColorScheme(name);
}
}
// look for this color scheme
QString path = findColorSchemePath(name);
if (!path.isEmpty() && loadColorScheme(path)) {
return findColorScheme(name);
}
qCDebug(KonsoleDebug) << "Could not find color scheme - " << name;
qCDebug(KonsoleDebug) << "Could not find color scheme - " << name;
return nullptr;
}
return nullptr;
}
QString ColorSchemeManager::findColorSchemePath(const QString &name) const
......
......@@ -63,38 +63,37 @@ uint ExtendedCharTable::createExtendedChar(const uint *unicodePoints, ushort len
// this sequence already has an entry in the table,
// return its hash
return hash;
} else {
// if hash is already used by another, different sequence of unicode character
// points then try next hash
hash++;
if (hash == initialHash) {
if (!triedCleaningSolution) {
triedCleaningSolution = true;
// All the hashes are full, go to all Screens and try to free any
// This is slow but should happen very rarely
QSet<uint> usedExtendedChars;
const QList<Session *> sessionsList = SessionManager::instance()->sessions();
for (const Session *s : sessionsList) {
const QList<TerminalDisplay *> displayList = s->views();
for (const TerminalDisplay *display : displayList) {
usedExtendedChars += display->screenWindow()->screen()->usedExtendedChars();
}
}
// if hash is already used by another, different sequence of unicode character
// points then try next hash
hash++;
if (hash == initialHash) {
if (!triedCleaningSolution) {
triedCleaningSolution = true;
// All the hashes are full, go to all Screens and try to free any
// This is slow but should happen very rarely
QSet<uint> usedExtendedChars;
const QList<Session *> sessionsList = SessionManager::instance()->sessions();
for (const Session *s : sessionsList) {
const QList<TerminalDisplay *> displayList = s->views();
for (const TerminalDisplay *display : displayList) {
usedExtendedChars += display->screenWindow()->screen()->usedExtendedChars();
}
}
QHash<uint, uint *>::iterator it = _extendedCharTable.begin();
QHash<uint, uint *>::iterator itEnd = _extendedCharTable.end();
while (it != itEnd) {
if (usedExtendedChars.contains(it.key())) {
++it;
} else {
it = _extendedCharTable.erase(it);
}
QHash<uint, uint *>::iterator it = _extendedCharTable.begin();
QHash<uint, uint *>::iterator itEnd = _extendedCharTable.end();
while (it != itEnd) {
if (usedExtendedChars.contains(it.key())) {
++it;
} else {
it = _extendedCharTable.erase(it);
}
} else {
qCDebug(KonsoleDebug) << "Using all the extended char hashes, going to miss this extended character";
return 0;
}
} else {
qCDebug(KonsoleDebug) << "Using all the extended char hashes, going to miss this extended character";
return 0;
}
}
}
......@@ -121,10 +120,9 @@ uint *ExtendedCharTable::lookupExtendedChar(uint hash, ushort &length) const
if (buffer != nullptr) {
length = ushort(buffer[0]);
return buffer + 1;
} else {
length = 0;
return nullptr;
}
}
length = 0;
return nullptr;
}
uint ExtendedCharTable::extendedCharHash(const uint *unicodePoints, ushort length) const
......
......@@ -440,9 +440,8 @@ QString MainWindow::activeSessionDir() const
session->getDynamicTitle();
}
return _pluggedController->currentDir();
} else {
return QString();
}
return QString();
}
void MainWindow::openUrls(const QList<QUrl> &urls)
......
......@@ -111,9 +111,8 @@ Session *Part::activeSession() const
Q_ASSERT(_viewManager->activeViewController()->session());
return _viewManager->activeViewController()->session();
} else {
return nullptr;
}
}
return nullptr;
}
void Part::startProgram(const QString &program, const QStringList &arguments)
......@@ -176,9 +175,8 @@ int Part::foregroundProcessId()
if (activeSession()->isForegroundProcessActive()) {
return activeSession()->foregroundProcessId();
} else {
return -1;
}
}
return -1;
}
QString Part::foregroundProcessName()
......@@ -187,9 +185,8 @@ QString Part::foregroundProcessName()
if (activeSession()->isForegroundProcessActive()) {
return activeSession()->foregroundProcessName();
} else {
return QString();
}
}
return QString();
}
QString Part::currentWorkingDirectory() const
......
......@@ -176,9 +176,8 @@ Profile::Ptr ProfileManager::loadProfile(const QString& shortPath)
if (recursionGuard.contains(path)) {
qCDebug(KonsoleDebug) << "Ignoring attempt to load profile recursively from" << path;
return _fallbackProfile;
} else {
recursionGuard.push(path);
}
recursionGuard.push(path);
// load the profile
ProfileReader reader;
......
......@@ -299,9 +299,8 @@ QRect ScreenWindow::scrollRegion() const
if (atEndOfOutput() && equalToScreenSize) {
return _screen->lastScrolledRegion();
} else {
return {0, 0, windowColumns(), windowLines()};
}
}
return {0, 0, windowColumns(), windowLines()};
}
void ScreenWindow::notifyOutputChanged()
......
......@@ -98,15 +98,14 @@ QVariant SessionListModel::headerData(int section, Qt::Orientation orientation,
if (orientation == Qt::Vertical) {
return QVariant();
} else {
switch (section) {
case 0:
return i18nc("@item:intable The session index", "Number");
case 1:
return i18nc("@item:intable The session title", "Title");
default:
return QVariant();
}
}
switch (section) {
case 0:
return i18nc("@item:intable The session index", "Number");
case 1:
return i18nc("@item:intable The session title", "Title");
default:
return QVariant();
}
}
......@@ -142,7 +141,6 @@ QModelIndex SessionListModel::index(int row, int column, const QModelIndex &pare
{
if (hasIndex(row, column, parent)) {
return createIndex(row, column, _sessions[row]);
} else {
return {};
}
}
return {};
}
......@@ -61,9 +61,8 @@ QString ShellCommand::command() const
{
if (!_arguments.isEmpty()) {
return _arguments[0];
} else {
return QString();
}
}
return QString();
}
QStringList ShellCommand::arguments() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment