mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL: Add a lookup cache StringMap to SILModule.
Because doing linear lookup all the time is dumb. NFC. Swift SVN r11575
This commit is contained in:
@@ -50,6 +50,23 @@ SILModule::~SILModule() {
|
||||
delete (SILTypeListUniquingType*)TypeListUniquing;
|
||||
}
|
||||
|
||||
SILFunction *SILModule::lookup(StringRef Name) {
|
||||
// Did we already find this?
|
||||
auto found = FunctionLookupCache.find(Name);
|
||||
if (found != FunctionLookupCache.end()) {
|
||||
return found->second;
|
||||
}
|
||||
|
||||
// If not, search through the function list, caching the entries we visit.
|
||||
for (SILFunction &F : *this) {
|
||||
FunctionLookupCache[F.getName()] = &F;
|
||||
if (F.getName() == Name) {
|
||||
return &F;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SILFunction *SILModule::getOrCreateSharedFunction(SILLocation loc,
|
||||
StringRef name,
|
||||
CanSILFunctionType type,
|
||||
|
||||
Reference in New Issue
Block a user