[PATCH] D62970: [clang-doc] De-duplicate comments

Jake Ehrlich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 6 14:32:52 PDT 2019


jakehehrlich added inline comments.


================
Comment at: clang-tools-extra/clang-doc/Representation.cpp:124
+  for (auto &Comment : Other.Description) {
+    bool IsCommentUnique = std::find(Description.begin(), Description.end(),
+                                     Comment) == Description.end();
----------------
juliehockett wrote:
> ```if (std::find(Description.begin(), Description.end(), Comment) == Description.end())
>   Description.emplace_back(std::move(Comment));```
Instead of deduping like this can we just make Description a set?


================
Comment at: clang-tools-extra/clang-doc/Representation.h:60-65
+    for (unsigned I = 0; I < Children.size(); ++I) {
+      if (!(*Children[I] == *Other.Children[I]))
+        return false;
+    }
+    return true;
+  }
----------------
You can do this using llvm::make_pointer_range/llvm::pointer_iterator and std::equal


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62970/new/

https://reviews.llvm.org/D62970





More information about the cfe-commits mailing list