File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -905,11 +905,17 @@ Decl *ClangTypeConverter::getSwiftDeclForExportedClangDecl(
905
905
}
906
906
907
907
clang::QualType ClangTypeConverter::convertTemplateArgument (Type type) {
908
- auto withCache = [&](auto lookup) {
909
- auto [it, inserted] = Cache.try_emplace (type, clang::QualType{});
910
- if (inserted)
911
- it->second = lookup ();
912
- return it->second ;
908
+ auto withCache = [&](auto conversion) {
909
+ auto cached = Cache.find (type);
910
+ if (cached != Cache.end ())
911
+ return cached->second ;
912
+
913
+ // Cache miss; perform the conversion and cache successful results
914
+ auto result = conversion ();
915
+
916
+ if (!result.isNull ())
917
+ Cache.insert ({type, result});
918
+ return result;
913
919
};
914
920
915
921
// This type was imported from Clang, so we can convert it back by retrieving
You can’t perform that action at this time.
0 commit comments