diff --git a/clang-tools-extra/clang-doc/Representation.cpp b/clang-tools-extra/clang-doc/Representation.cpp --- a/clang-tools-extra/clang-doc/Representation.cpp +++ b/clang-tools-extra/clang-doc/Representation.cpp @@ -54,51 +54,15 @@ return -1; } -void reduceChildren(std::vector &Children, - std::vector &&ChildrenToMerge) { - for (auto &ChildToMerge : ChildrenToMerge) { - int mergeIdx = getChildIndexIfExists(Children, ChildToMerge); - if (mergeIdx == -1) { - Children.push_back(std::move(ChildToMerge)); - continue; - } - Children[mergeIdx].merge(std::move(ChildToMerge)); - } -} - -void reduceChildren(std::vector &Children, - std::vector &&ChildrenToMerge) { - for (auto &ChildToMerge : ChildrenToMerge) { - int mergeIdx = getChildIndexIfExists(Children, ChildToMerge); - if (mergeIdx == -1) { - Children.push_back(std::move(ChildToMerge)); - continue; - } - Children[mergeIdx].merge(std::move(ChildToMerge)); - } -} - -void reduceChildren(std::vector &Children, - std::vector &&ChildrenToMerge) { - for (auto &ChildToMerge : ChildrenToMerge) { - int mergeIdx = getChildIndexIfExists(Children, ChildToMerge); - if (mergeIdx == -1) { - Children.push_back(std::move(ChildToMerge)); - continue; - } - Children[mergeIdx].merge(std::move(ChildToMerge)); - } -} - -void reduceChildren(std::vector &Children, - std::vector &&ChildrenToMerge) { +template +void reduceChildren(std::vector &Children, std::vector &&ChildrenToMerge){ for (auto &ChildToMerge : ChildrenToMerge) { - int mergeIdx = getChildIndexIfExists(Children, ChildToMerge); - if (mergeIdx == -1) { + int MergeIdx = getChildIndexIfExists(Children, ChildToMerge); + if (MergeIdx == -1) { Children.push_back(std::move(ChildToMerge)); continue; } - Children[mergeIdx].merge(std::move(ChildToMerge)); + Children[MergeIdx].merge(std::move(ChildToMerge)); } }