[PATCH] D130864: [NFC] Introduce ASTContext::isInSameModule()

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 1 20:07:49 PDT 2022

ChuanqiXu marked 2 inline comments as done.
ChuanqiXu added inline comments.

Comment at: clang/lib/AST/ASTContext.cpp:6232
+  auto getHashValueForPrimaryModule = [this](const Module *M) {
+    if (!PrimaryModuleHash.count(M))
erichkeane wrote:
> Doesn't `FindAndConstruct` do something pretty similar here?  This lambda is incredibly inefficient as it requires two 3 separate lookups into the map.
> Instead, I believe `FindAndConstruct` will create a new entry (which can be 'set' if necessary', and then have its value returned.
On the one hand, `FindAndConstruct ` would construct an empty value, which is not we want. We want the value to be a hash_value of the name. On the other hand, your comments makes sense the implementation could be optimized. Currently, there would be at most 2 lookups and the number should be 1 at the hot path.



More information about the cfe-commits mailing list