From 0c836ebc47cab2f37274ae03ab2be6c7b2fd0456 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 6 May 2014 14:08:17 -0700 Subject: Simplify string comparison This is based on Linus' idea on the mailing list. Treat NULL strings and empty strings as identical. Suggested-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ec4065d85..5bcc07cf9 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -856,12 +856,11 @@ void MainTab::rejectChanges() // this macro is rather fragile and is intended to be used as WHAT inside // an invocation of EDIT_SELECTED_DIVES(WHAT) -#define EDIT_TEXT(what, text) \ - if ((!mydive->what && !current_dive->what) || \ - (mydive->what && current_dive->what && strcmp(mydive->what, current_dive->what) == 0)) { \ - QByteArray textByteArray = text.toUtf8(); \ - free(mydive->what); \ - mydive->what = strdup(textByteArray.data()); \ +#define EDIT_TEXT(what, text) \ + if (same_string(mydive->what, current_dive->what)) { \ + QByteArray textByteArray = text.toUtf8(); \ + free(mydive->what); \ + mydive->what = strdup(textByteArray.data()); \ } #define EDIT_VALUE(what, value) \ -- cgit v1.2.3-70-g09d2