From: Matthew Fernandez Date: Thu, 13 May 2021 00:08:31 +0000 (-0700) Subject: use isEmpty in preference to checking length against 0 in gvedit X-Git-Tag: 2.47.2~5^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac4217ef2f9a40288359b74102c91ed18a5eebe4;p=graphviz use isEmpty in preference to checking length against 0 in gvedit Qt QStrings have two methods, isEmpty and length, analogous to empty and length on std::string, respectively. Checking isEmpty is equivalent to checking length against 0, is clearer, and has the potential to be more performant. --- diff --git a/cmd/gvedit/csettings.cpp b/cmd/gvedit/csettings.cpp index 1905460fe..79540e093 100644 --- a/cmd/gvedit/csettings.cpp +++ b/cmd/gvedit/csettings.cpp @@ -199,7 +199,7 @@ void CFrmSettings::addSlot() } QString _value = WIDGET(QLineEdit, leValue)->text(); - if (_value.trimmed().length() == 0) + if (_value.trimmed().isEmpty()) QMessageBox::warning(this, tr("GvEdit"), tr ("Please enter a value for selected attribute!"), @@ -268,8 +268,7 @@ void CFrmSettings::openSlot() void CFrmSettings::saveSlot() { - if (WIDGET(QTextEdit, teAttributes)->toPlainText().trimmed(). - length() == 0) { + if (WIDGET(QTextEdit, teAttributes)->toPlainText().trimmed().isEmpty()) { QMessageBox::warning(this, tr("GvEdit"), tr("Nothing to save!"), QMessageBox::Ok, QMessageBox::Ok); return; diff --git a/cmd/gvedit/mainwindow.cpp b/cmd/gvedit/mainwindow.cpp index 0d1ef3918..cfebeb29a 100644 --- a/cmd/gvedit/mainwindow.cpp +++ b/cmd/gvedit/mainwindow.cpp @@ -322,7 +322,7 @@ void CMainWindow::slotNewLog() void CMainWindow::slotSaveLog() { - if (globTextEdit->toPlainText().trimmed().length() == 0) { + if (globTextEdit->toPlainText().trimmed().isEmpty()) { QMessageBox::warning(this, tr("GvEdit"), tr("Nothing to save!"), QMessageBox::Ok, QMessageBox::Ok); return;