[PATCH] D142564: [clang-doc] Reduce duplicate code with template
Paul Kirth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 26 10:05:42 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9470de65bb33: [clang-doc] Reduce duplicate code with template (authored by paulkirth).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142564/new/
https://reviews.llvm.org/D142564
Files:
clang-tools-extra/clang-doc/Representation.cpp
Index: clang-tools-extra/clang-doc/Representation.cpp
===================================================================
--- clang-tools-extra/clang-doc/Representation.cpp
+++ clang-tools-extra/clang-doc/Representation.cpp
@@ -54,51 +54,16 @@
return -1;
}
-void reduceChildren(std::vector<Reference> &Children,
- std::vector<Reference> &&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<FunctionInfo> &Children,
- std::vector<FunctionInfo> &&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<EnumInfo> &Children,
- std::vector<EnumInfo> &&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<TypedefInfo> &Children,
- std::vector<TypedefInfo> &&ChildrenToMerge) {
+template <typename T>
+void reduceChildren(std::vector<T> &Children,
+ std::vector<T> &&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));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142564.492500.patch
Type: text/x-patch
Size: 2164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230126/7545dd6c/attachment.bin>
More information about the cfe-commits
mailing list