From c09c7ccba00652dc146df26c161474c9d6283a44 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 30 Sep 2022 18:25:23 +0200 Subject: [PATCH] Differ: Fix broken logical XOR I bet the intention was to do logical XOR operation. In cpp it's done with operator!=(). Amends: 24a25eed1481a7c563431d79e3ad07840c0f7125 Change-Id: Idfc5dbf09b4f4b6c81aa237a956d5d4e04155c09 Reviewed-by: Alessandro Portale --- src/libs/utils/differ.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libs/utils/differ.cpp b/src/libs/utils/differ.cpp index 8c37d420e7b..7e06359d14b 100644 --- a/src/libs/utils/differ.cpp +++ b/src/libs/utils/differ.cpp @@ -496,7 +496,7 @@ static QString encodeExpandedWhitespace(const QString &leftEquality, *ok = false; if (!leftCodeMap || !rightCodeMap) - return QString(); + return {}; leftCodeMap->clear(); rightCodeMap->clear(); @@ -520,17 +520,17 @@ static QString encodeExpandedWhitespace(const QString &leftEquality, if (leftIndex < leftCount && rightIndex < rightCount) { if (leftEquality.at(leftIndex) != rightEquality.at(rightIndex)) - return QString(); // equalities broken + return {}; // equalities broken } else if (leftIndex == leftCount && rightIndex == rightCount) { ; // do nothing, the last iteration } else { - return QString(); // equalities broken + return {}; // equalities broken } - if (leftWhitespaces.isEmpty() ^ rightWhitespaces.isEmpty()) { + if (leftWhitespaces.isEmpty() != rightWhitespaces.isEmpty()) { // there must be at least 1 corresponding whitespace, equalities broken - return QString(); + return {}; } if (!leftWhitespaces.isEmpty() && !rightWhitespaces.isEmpty()) { @@ -1233,8 +1233,7 @@ QStringList Differ::encode(const QString &text1, QString *encodedText1, QString *encodedText2) { - QStringList lines; - lines.append(QString()); // don't use code: 0 + QStringList lines{{}}; // don't use code: 0 QMap lineToCode; *encodedText1 = encode(text1, &lines, &lineToCode);