7474#include " llvm/ADT/StringExtras.h"
7575#include " llvm/ADT/StringMap.h"
7676#include " llvm/ADT/StringSwitch.h"
77+ #include " llvm/ADT/TinyPtrVector.h"
7778#include " llvm/Support/Path.h"
7879
7980#include < algorithm>
@@ -2578,11 +2579,11 @@ namespace {
25782579 Impl.addAlternateDecl (subscriptImpl, subscript);
25792580 }
25802581
2581- if ( Impl.cxxDereferenceOperators .find (result) !=
2582- Impl.cxxDereferenceOperators .end ()) {
2582+ auto getterAndSetterIt = Impl.cxxDereferenceOperators .find (result);
2583+ if (getterAndSetterIt != Impl.cxxDereferenceOperators .end ()) {
25832584 // If this type has a dereference operator, synthesize a computed
25842585 // property called `pointee` for it.
2585- auto getterAndSetter = Impl. cxxDereferenceOperators [result] ;
2586+ auto getterAndSetter = getterAndSetterIt-> second ;
25862587
25872588 VarDecl *pointeeProperty =
25882589 synthesizer.makeDereferencedPointeeProperty (
@@ -5076,10 +5077,9 @@ namespace {
50765077
50775078 // Check whether there's some special method to import.
50785079 if (!forceClassMethod) {
5079- if (dc == Impl.importDeclContextOf (decl, decl->getDeclContext ()) &&
5080- !Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}])
5081- Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}]
5082- = result;
5080+ if (dc == Impl.importDeclContextOf (decl, decl->getDeclContext ()))
5081+ Impl.ImportedDecls .try_emplace (
5082+ {decl->getCanonicalDecl (), getVersion ()}, result);
50835083
50845084 if (importedName.isSubscriptAccessor ()) {
50855085 // If this was a subscript accessor, try to create a
@@ -7696,8 +7696,8 @@ SwiftDeclConverter::importSubscript(Decl *decl,
76967696
76977697 // Note that we've created this subscript.
76987698 Impl.Subscripts [{getter, setter}] = subscript;
7699- if (setter && !Impl. Subscripts [{getter, nullptr }] )
7700- Impl.Subscripts [ {getter, nullptr }] = subscript;
7699+ if (setter)
7700+ Impl.Subscripts . try_emplace ( {getter, nullptr }, subscript) ;
77017701
77027702 // Make the getter/setter methods unavailable.
77037703 if (!getter->isUnavailable ())
@@ -8413,11 +8413,12 @@ SourceFile &ClangImporter::Implementation::getClangSwiftAttrSourceFile(
84138413 StringRef attributeText,
84148414 bool cached
84158415) {
8416+ ::TinyPtrVector<SourceFile *> *sourceFiles = nullptr ;
84168417 if (cached) {
8417- auto & sourceFiles = ClangSwiftAttrSourceFiles[attributeText];
8418+ sourceFiles = & ClangSwiftAttrSourceFiles[attributeText];
84188419
84198420 // Check whether we've already created a source file.
8420- for (auto sourceFile : sourceFiles) {
8421+ for (auto sourceFile : * sourceFiles) {
84218422 if (sourceFile->getParentModule () == &module )
84228423 return *sourceFile;
84238424 }
@@ -8443,10 +8444,8 @@ SourceFile &ClangImporter::Implementation::getClangSwiftAttrSourceFile(
84438444 auto sourceFile = new (SwiftContext)
84448445 SourceFile (module , SourceFileKind::Library, bufferID);
84458446
8446- if (cached) {
8447- auto &sourceFiles = ClangSwiftAttrSourceFiles[attributeText];
8448- sourceFiles.push_back (sourceFile);
8449- }
8447+ if (cached)
8448+ sourceFiles->push_back (sourceFile);
84508449
84518450 return *sourceFile;
84528451}
@@ -9839,9 +9838,9 @@ ClangImporter::Implementation::importDeclContextOf(
98399838 // Clang submodule of the declaration.
98409839 const clang::Module *declSubmodule = *getClangSubmoduleForDecl (decl);
98419840 auto extensionKey = std::make_pair (nominal, declSubmodule);
9842- auto knownExtension = extensionPoints.find (extensionKey);
9843- if (knownExtension != extensionPoints. end () )
9844- return knownExtension-> second ;
9841+ auto [it, inserted] = extensionPoints.try_emplace (extensionKey, nullptr );
9842+ if (!inserted )
9843+ return it-> getSecond () ;
98459844
98469845 // Create a new extension for this nominal type/Clang submodule pair.
98479846 auto ext = ExtensionDecl::create (SwiftContext, SourceLoc (), nullptr , {},
@@ -9854,7 +9853,7 @@ ClangImporter::Implementation::importDeclContextOf(
98549853 // Record this extension so we can find it later. We do this early because
98559854 // once we've set the member loader, we don't know when the compiler will use
98569855 // it and end up back in this method.
9857- extensionPoints[extensionKey] = ext;
9856+ it-> getSecond () = ext;
98589857 ext->setMemberLoader (this , reinterpret_cast <uintptr_t >(declSubmodule));
98599858
98609859 if (auto protoDecl = ext->getExtendedProtocolDecl ()) {
0 commit comments