]> granicus.if.org Git - graphviz/commitdiff
use isEmpty in preference to checking length against 0 in gvedit
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 13 May 2021 00:08:31 +0000 (17:08 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 19 May 2021 02:42:15 +0000 (19:42 -0700)
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.

cmd/gvedit/csettings.cpp
cmd/gvedit/mainwindow.cpp

index 1905460fe334f7e2a8160cd1a9104d6497e8f0b0..79540e0936aaba056a8320349187481aaee183b2 100644 (file)
@@ -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;
index 0d1ef39185ce42e6c22bc6ddb1bb8354e0bdfece..cfebeb29a2d81de97fad0992e5077bde17d7795a 100644 (file)
@@ -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;