Skip to content

Commit

Permalink
[C++20][Modules] Improve efficiency of isModulePartition method.
Browse files Browse the repository at this point in the history
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.

Differential Revision: https://reviews.llvm.org/D120764
  • Loading branch information
iains committed Mar 2, 2022
1 parent 7a02abf commit 17ce549
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions clang/include/clang/Basic/Module.h
Expand Up @@ -515,12 +515,14 @@ class Module {
}

/// 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);
}
Expand Down

0 comments on commit 17ce549

Please sign in to comment.