[PATCH] D120764: [C++20][Modules] Improve efficiency of isModuleParition method.

Iain Sandoe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 1 12:49:31 PST 2022


iains created this revision.
Herald added a subscriber: dexonsmith.
Herald added a project: All.
iains added reviewers: urnathan, ChuanqiXu.
iains published this revision for review.
iains added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This should improve the efficiency  in the demangler use-case.


The original implementation of this used the presence of a ":" in the module
name as the key, but since we now generate modules with the correct kind, we
can just test that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120764

Files:
  clang/include/clang/Basic/Module.h


Index: clang/include/clang/Basic/Module.h
===================================================================
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -515,12 +515,14 @@
   }
 
   /// Is this a module partition.
-  bool isModulePartition() const { return Name.find(':') != std::string::npos; }
+  bool isModulePartition() const {
+    return Kind == ModulePartitionInterface ||
+           Kind == ModulePartitionImplementation;
+  }
 
   /// Get the primary module interface name from a partition.
   StringRef getPrimaryModuleInterfaceName() const {
-    if (Kind == ModulePartitionInterface ||
-        Kind == ModulePartitionImplementation) {
+    if (isModulePartition()) {
       auto pos = Name.find(':');
       return StringRef(Name.data(), pos);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120764.412206.patch
Type: text/x-patch
Size: 803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220301/2fce5cd3/attachment.bin>


More information about the cfe-commits mailing list