Commit 969d52c1 authored by Filip Gawin's avatar Filip Gawin

Avoid using `size` for checking emptiness

(Use dedicated `empty` for it)
parent 7846a5a5
......@@ -93,7 +93,7 @@ void KateBtBrowserTest::testParser()
bt = QStringLiteral(" Thread 1 (Thread 0x7fb6ba260780 (LWP 16447)):\n[KCrash Handler]");
info = KateBtParser::parseBacktrace(bt);
QVERIFY(info.size() == 0);
QVERIFY(info.empty());
}
// kate: space-indent on; indent-width 4; replace-tabs on;
......@@ -64,7 +64,7 @@ QString KateBtDatabase::value(const QString &key)
}
}
// try to use the first one
if (sl.size() > 0) {
if (!sl.empty()) {
return sl[0];
}
}
......
......@@ -51,7 +51,7 @@ void BtFileIndexer::setFilter(const QStringList &fileFilter)
void BtFileIndexer::run()
{
if (filter.size() == 0) {
if (filter.empty()) {
qDebug() << "Filter is empty. Aborting.";
return;
}
......
......@@ -361,7 +361,7 @@ void KateBtConfigWidget::add()
{
QDir url(edtUrl->lineEdit()->text());
if (url.exists())
if (lstFolders->findItems(url.absolutePath(), Qt::MatchExactly).size() == 0) {
if (lstFolders->findItems(url.absolutePath(), Qt::MatchExactly).empty()) {
lstFolders->addItem(url.absolutePath());
emit changed();
m_changed = true;
......
......@@ -325,7 +325,7 @@ void ConfigView::slotAddTarget()
void ConfigView::slotCopyTarget()
{
QStringList tmp = m_targetCombo->itemData(m_targetCombo->currentIndex()).toStringList();
if (tmp.size() < 1) {
if (tmp.empty()) {
slotAddTarget();
return;
}
......
......@@ -195,7 +195,7 @@ void DebugView::slotDebugFinished(int /*exitCode*/, QProcess::ExitStatus status)
// remove all old breakpoints
BreakPoint bPoint;
while (m_breakPointList.size() > 0)
while (!m_breakPointList.empty())
{
bPoint = m_breakPointList.takeFirst();
emit breakPointCleared(bPoint.file, bPoint.line -1);
......@@ -404,7 +404,7 @@ void DebugView::processLine(QString line)
{
// if there are still commands to execute remove them to remove unneeded output
// except if the "kill was for "re-run"
if ((m_nextCommands.size() > 0) && !m_nextCommands[0].contains(QStringLiteral("file")))
if ((!m_nextCommands.empty()) && !m_nextCommands[0].contains(QStringLiteral("file")))
{
m_nextCommands.clear();
}
......@@ -501,7 +501,7 @@ void DebugView::processLine(QString line)
void DebugView::processErrors()
{
QString error;
while (m_errorList.size() > 0) {
while (!m_errorList.empty()) {
error = m_errorList.takeFirst();
//qDebug() << error;
if(error == QLatin1String("The program is not being run."))
......@@ -527,7 +527,7 @@ void DebugView::processErrors()
}
else if ((m_lastCommand == QLatin1String("kill")))
{
if (m_nextCommands.size() > 0)
if (!m_nextCommands.empty())
{
if (!m_nextCommands[0].contains(QStringLiteral("file")))
{
......@@ -606,7 +606,7 @@ void DebugView::issueNextCommand()
{
if(m_state == ready)
{
if(m_nextCommands.size() > 0)
if(!m_nextCommands.empty())
{
QString cmd = m_nextCommands.takeFirst();
//qDebug() << "Next command" << cmd;
......@@ -683,7 +683,7 @@ void DebugView::outputTextMaybe(const QString &text)
void DebugView::slotQueryLocals(bool query)
{
m_queryLocals = query;
if (query && (m_state == ready) && (m_nextCommands.size() == 0))
if (query && (m_state == ready) && (m_nextCommands.empty()))
{
m_nextCommands << QStringLiteral("(Q)info stack");
m_nextCommands << QStringLiteral("(Q)frame");
......
......@@ -243,7 +243,7 @@ void KateCTagsView::lookupTag( )
setNewLookupText(currWord);
Tags::TagList list = Tags::getExactMatches(m_ctagsUi.tagsFile->text(), currWord);
if (list.size() == 0) list = Tags::getExactMatches(m_commonDB, currWord);
if (list.empty()) list = Tags::getExactMatches(m_commonDB, currWord);
displayHits(list);
// activate the hits tab
......@@ -255,7 +255,7 @@ void KateCTagsView::lookupTag( )
void KateCTagsView::editLookUp()
{
Tags::TagList list = Tags::getPartialMatches(m_ctagsUi.tagsFile->text(), m_ctagsUi.inputEdit->text());
if (list.size() == 0) list = Tags::getPartialMatches(m_commonDB, m_ctagsUi.inputEdit->text());
if (list.empty()) list = Tags::getPartialMatches(m_commonDB, m_ctagsUi.inputEdit->text());
displayHits(list);
}
......@@ -298,7 +298,7 @@ void KateCTagsView::gotoDeclaration( )
void KateCTagsView::gotoTagForTypes(const QString &word, const QStringList &types)
{
Tags::TagList list = Tags::getMatches(m_ctagsUi.tagsFile->text(), word, false, types);
if (list.size() == 0) list = Tags::getMatches(m_commonDB, word, false, types);
if (list.empty()) list = Tags::getMatches(m_commonDB, word, false, types);
//qCDebug(KTECTAGS) << "found" << list.count() << word << types;
setNewLookupText(word);
......
......@@ -1256,7 +1256,7 @@ public:
template<typename Collection>
void checkEditResult(const Collection &c)
{
if (c.size() == 0) {
if (c.empty()) {
showMessage(i18n("No edits"), KTextEditor::Message::Information);
}
}
......@@ -1427,7 +1427,7 @@ public:
if (!topItem) {
// no need to create an empty one
if (diagnostics.diagnostics.size() == 0) {
if (diagnostics.diagnostics.empty()) {
return;
}
topItem = new QStandardItem();
......@@ -1507,7 +1507,7 @@ public:
void onTextChanged(KTextEditor::Document *doc)
{
if (m_onTypeFormattingTriggers.size() == 0)
if (m_onTypeFormattingTriggers.empty())
return;
KTextEditor::View *activeView = m_mainWindow->activeView();
......
......@@ -496,7 +496,7 @@ static QList<LSPCompletionItem> parseDocumentCompletion(const QJsonValue &result
QList<LSPCompletionItem> ret;
QJsonArray items = result.toArray();
// might be CompletionList
if (items.size() == 0) {
if (items.empty()) {
items = result.toObject().value(QStringLiteral("items")).toArray();
}
for (const auto &vitem : items) {
......@@ -1088,7 +1088,7 @@ public:
void didChange(const QUrl &document, int version, const QString &text,
const QList<LSPTextDocumentContentChangeEvent> &changes)
{
Q_ASSERT(text.size() == 0 || changes.size() == 0);
Q_ASSERT(text.isEmpty() || changes.empty());
auto params = textDocumentParams(document, version);
params[QStringLiteral("contentChanges")] = text.size()
? QJsonArray { QJsonObject { { MEMBER_TEXT, text } } }
......
......@@ -724,7 +724,7 @@ private:
if (it->modified || force) {
(it->server)
->didChange(it->url, it->version,
(it->changes.size() == 0) ? doc->text() : QString(),
(it->changes.empty()) ? doc->text() : QString(),
it->changes);
}
} else {
......
......@@ -37,7 +37,7 @@ SearchDiskFiles::~SearchDiskFiles()
void SearchDiskFiles::startSearch(const QStringList &files,
const QRegularExpression &regexp)
{
if (files.size() == 0) {
if (files.empty()) {
emit searchDone();
return;
}
......
......@@ -737,7 +737,7 @@ void KatePluginSearchView::folderFileListChanged()
// search order is important: Open files starts immediately and should finish
// earliest after first event loop.
// The DiskFile might finish immediately
if (openList.size() > 0) {
if (!openList.empty()) {
m_searchOpenFiles.startSearch(openList, m_curResults->regExp);
}
else {
......@@ -1163,7 +1163,7 @@ void KatePluginSearchView::startSearch()
// search order is important: Open files starts immediately and should finish
// earliest after first event loop.
// The DiskFile might finish immediately
if (openList.size() > 0) {
if (!openList.empty()) {
m_searchOpenFiles.startSearch(openList, m_curResults->regExp);
} else {
m_searchOpenFilesDone = true;
......
......@@ -143,7 +143,7 @@ void KateSessionManagerTest::saveActiveSessionWithAnynomous()
{
QVERIFY(m_manager->activateAnonymousSession());
QVERIFY(m_manager->activeSession()->isAnonymous());
QVERIFY(m_manager->sessionList().size() == 0);
QVERIFY(m_manager->sessionList().empty());
QCOMPARE(m_manager->saveActiveSession(), true);
QCOMPARE(m_manager->activeSession()->isAnonymous(), true);
......
......@@ -294,7 +294,7 @@ bool KateDocManager::closeDocumentList(const QList<KTextEditor::Document *>& doc
}
}
if (modifiedDocuments.size() > 0 && !KateSaveModifiedDialog::queryClose(nullptr, modifiedDocuments)) {
if (!modifiedDocuments.empty() && !KateSaveModifiedDialog::queryClose(nullptr, modifiedDocuments)) {
return false;
}
......
......@@ -469,7 +469,7 @@ void KateMainWindow::setupActions()
void KateMainWindow::slotDocumentCloseAll()
{
if (KateApp::self()->documentManager()->documentList().size() >= 1 && KMessageBox::warningContinueCancel(this,
if (!KateApp::self()->documentManager()->documentList().empty() && KMessageBox::warningContinueCancel(this,
i18n("This will close all open documents. Are you sure you want to continue?"),
i18n("Close all documents"),
KStandardGuiItem::cont(),
......
......@@ -410,7 +410,7 @@ bool KateSessionManager::chooseSession()
}
// start with empty new session or in case no sessions exist
if (sesStart == QStringLiteral("new") || sessionList().size() == 0) {
if (sesStart == QStringLiteral("new") || sessionList().empty()) {
return activateAnonymousSession();
}
......
......@@ -43,7 +43,7 @@ KateSessionsAction::KateSessionsAction(const QString &text, QObject *parent, Kat
connect(m_manager, &KateSessionManager::sessionChanged, this, &KateSessionsAction::slotSessionChanged);
setDisabled(m_manager->sessionList().size() == 0);
setDisabled(m_manager->sessionList().empty());
}
void KateSessionsAction::slotAboutToShow()
......@@ -77,6 +77,6 @@ void KateSessionsAction::openSession(QAction *action)
void KateSessionsAction::slotSessionChanged()
{
setDisabled(m_manager->sessionList().size() == 0);
setDisabled(m_manager->sessionList().empty());
}
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