llvm-project
22328817 - [C++20] [Modules] Avoid comparing primary module name to decide isInSameModule all the time

Commit
1 year ago
[C++20] [Modules] Avoid comparing primary module name to decide isInSameModule all the time Previously, we decide if two module units are in the same module by comparing name of the primary module interface. But it looks not efficiency if we always compare the strings. It should be good to avoid the expensive string operations if possible. In this patch, we introduced a `llvm::StringMap` to map primary module name to a Module* and a `llvm::DenseMap<Module*, Module*>` to map a Module* to a representative Module *. The representative Module* is one of the Module units belonging to a certain module. The module units have the same representative Module* should belong to the same module. We choose the representative Module* by the first module lookup for a certain primary module name. So the following module units have the same primary module name would get the same representative modules. So that for every modules, there will be only one hash process for the primary module name.
Author
Committer
Parents
Loading