[clang-tools-extra] [clang-doc] Improve performance by adding a short circuit (PR #96809)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 11 07:35:38 PDT 2024
================
@@ -12,16 +12,31 @@
#include "clang/AST/Comment.h"
#include "clang/Index/USRGeneration.h"
#include "llvm/ADT/StringExtras.h"
-#include "llvm/Support/Error.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/Mutex.h"
namespace clang {
namespace doc {
+static llvm::StringSet USRVisited;
+static llvm::sys::Mutex USRVisitedGuard;
+
+
+template <typename T> bool isTypedefAnonRecord(const T* D) {
+ if (const auto *C = dyn_cast<CXXRecordDecl>(D)) {
+ if (const TypedefNameDecl *TD = C->getTypedefNameForAnonDecl()) {
+ return true;
+ }
----------------
ilovepi wrote:
```suggestion
return C->getTypedefNameForAnonDecl();
```
Isn't this just the same. You still need the outer return, but this doesn't need a branch and temporary.
https://github.com/llvm/llvm-project/pull/96809
More information about the cfe-commits
mailing list