From 7c96bb6e2ff74b32a0081b9407f769c9c0c6e270 Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Wed, 4 Jul 2018 08:27:28 +0000 Subject: [PATCH] [clangd] FileDistance: don't add duplicate edges llvm-svn: 336242 --- clang-tools-extra/clangd/FileDistance.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clangd/FileDistance.cpp b/clang-tools-extra/clangd/FileDistance.cpp index 74cbc61..49fe56e 100644 --- a/clang-tools-extra/clangd/FileDistance.cpp +++ b/clang-tools-extra/clangd/FileDistance.cpp @@ -72,7 +72,9 @@ FileDistance::FileDistance(StringMap Sources, for (unsigned I = 0; !Rest.empty(); ++I) { Rest = parent_path(Rest, sys::path::Style::posix); auto NextHash = hash_value(Rest); - DownEdges[NextHash].push_back(Hash); + auto &Down = DownEdges[NextHash]; + if (std::find(Down.begin(), Down.end(), Hash) == Down.end()) + DownEdges[NextHash].push_back(Hash); // We can't just break after MaxUpTraversals, must still set DownEdges. if (I > S.getValue().MaxUpTraversals) { if (Cache.find(Hash) != Cache.end()) -- 2.7.4