From aca14a36e9231d37c00379e13ebf6bcbdd248ddb Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 22 Aug 2018 17:35:22 +0200 Subject: [PATCH] Clang: Use only filePathId for comparison The filePathId is already unique and the directoryId is there only to improve the access time for the directory. So it is already strongly ordered if we compare only filePathId. Change-Id: I67255bea1d36d41a59421eeb51964440c053b1e3 Reviewed-by: Ivan Donchevskii --- src/libs/clangsupport/filepathid.h | 8 ++------ tests/unit/unittest/projectpartqueue-test.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/libs/clangsupport/filepathid.h b/src/libs/clangsupport/filepathid.h index a08a162ed59..38762bd44bf 100644 --- a/src/libs/clangsupport/filepathid.h +++ b/src/libs/clangsupport/filepathid.h @@ -51,10 +51,7 @@ public: friend bool operator==(FilePathId first, FilePathId second) { - return first.isValid() - && second.isValid() - && first.directoryId == second.directoryId - && first.filePathId == second.filePathId; + return first.isValid() && first.filePathId == second.filePathId; } friend bool operator!=(FilePathId first, FilePathId second) @@ -64,8 +61,7 @@ public: friend bool operator<(FilePathId first, FilePathId second) { - return std::tie(first.directoryId, first.filePathId) - < std::tie(second.directoryId, second.filePathId); + return first.filePathId < second.filePathId; } friend QDataStream &operator<<(QDataStream &out, const FilePathId &filePathId) diff --git a/tests/unit/unittest/projectpartqueue-test.cpp b/tests/unit/unittest/projectpartqueue-test.cpp index f13d0f55780..b6892df0872 100644 --- a/tests/unit/unittest/projectpartqueue-test.cpp +++ b/tests/unit/unittest/projectpartqueue-test.cpp @@ -43,26 +43,26 @@ protected: {"--er"}, {{"ER","2"}}, {"/bar"}, - {{2, 1}}, - {{2, 2}}}; + {{2, 3}}, + {{2, 4}}}; ClangBackEnd::V2::ProjectPartContainer projectPart2b{"ProjectPart2", {"--liang"}, {{"LIANG","3"}}, {"/liang"}, - {{2, 3}}, - {{2, 2}, {2, 4}}}; + {{2, 5}}, + {{2, 4}, {2, 6}}}; ClangBackEnd::V2::ProjectPartContainer projectPart3{"ProjectPart3", {"--san"}, {{"SAN","2"}}, {"/SAN"}, - {{3, 1}}, - {{3, 2}}}; + {{3, 7}}, + {{3, 8}}}; ClangBackEnd::V2::ProjectPartContainer projectPartMerged{"ProjectPart2", {"--liang"}, {{"LIANG","3"}}, {"/liang"}, - {{2, 1}, {2, 3}}, - {{2, 2}, {2, 4}}}; + {{2, 3}, {2, 5}}, + {{2, 4}, {2, 6}}}; }; TEST_F(ProjectPartQueue, AddProjectPart)