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>
@@ -2574,11 +2575,11 @@ namespace {
25742575 Impl.addAlternateDecl (subscriptImpl, subscript);
25752576 }
25762577
2577- if ( Impl.cxxDereferenceOperators .find (result) !=
2578- Impl.cxxDereferenceOperators .end ()) {
2578+ auto getterAndSetterIt = Impl.cxxDereferenceOperators .find (result);
2579+ if (getterAndSetterIt != Impl.cxxDereferenceOperators .end ()) {
25792580 // If this type has a dereference operator, synthesize a computed
25802581 // property called `pointee` for it.
2581- auto getterAndSetter = Impl. cxxDereferenceOperators [result] ;
2582+ auto getterAndSetter = getterAndSetterIt-> second ;
25822583
25832584 VarDecl *pointeeProperty =
25842585 synthesizer.makeDereferencedPointeeProperty (
@@ -5119,10 +5120,9 @@ namespace {
51195120
51205121 // Check whether there's some special method to import.
51215122 if (!forceClassMethod) {
5122- if (dc == Impl.importDeclContextOf (decl, decl->getDeclContext ()) &&
5123- !Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}])
5124- Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}]
5125- = result;
5123+ if (dc == Impl.importDeclContextOf (decl, decl->getDeclContext ()))
5124+ Impl.ImportedDecls .try_emplace (
5125+ {decl->getCanonicalDecl (), getVersion ()}, result);
51265126
51275127 if (importedName.isSubscriptAccessor ()) {
51285128 // If this was a subscript accessor, try to create a
@@ -7780,8 +7780,8 @@ SwiftDeclConverter::importSubscript(Decl *decl,
77807780
77817781 // Note that we've created this subscript.
77827782 Impl.Subscripts [{getter, setter}] = subscript;
7783- if (setter && !Impl. Subscripts [{getter, nullptr }] )
7784- Impl.Subscripts [ {getter, nullptr }] = subscript;
7783+ if (setter)
7784+ Impl.Subscripts . try_emplace ( {getter, nullptr }, subscript) ;
77857785
77867786 // Make the getter/setter methods unavailable.
77877787 if (!getter->isUnavailable ())
@@ -8497,11 +8497,12 @@ SourceFile &ClangImporter::Implementation::getClangSwiftAttrSourceFile(
84978497 StringRef attributeText,
84988498 bool cached
84998499) {
8500+ ::TinyPtrVector<SourceFile *> *sourceFiles = nullptr ;
85008501 if (cached) {
8501- auto & sourceFiles = ClangSwiftAttrSourceFiles[attributeText];
8502+ sourceFiles = & ClangSwiftAttrSourceFiles[attributeText];
85028503
85038504 // Check whether we've already created a source file.
8504- for (auto sourceFile : sourceFiles) {
8505+ for (auto sourceFile : * sourceFiles) {
85058506 if (sourceFile->getParentModule () == &module )
85068507 return *sourceFile;
85078508 }
@@ -8527,10 +8528,8 @@ SourceFile &ClangImporter::Implementation::getClangSwiftAttrSourceFile(
85278528 auto sourceFile = new (SwiftContext)
85288529 SourceFile (module , SourceFileKind::Library, bufferID);
85298530
8530- if (cached) {
8531- auto &sourceFiles = ClangSwiftAttrSourceFiles[attributeText];
8532- sourceFiles.push_back (sourceFile);
8533- }
8531+ if (cached)
8532+ sourceFiles->push_back (sourceFile);
85348533
85358534 return *sourceFile;
85368535}
@@ -9880,9 +9879,9 @@ ClangImporter::Implementation::importDeclContextOf(
98809879 // Clang submodule of the declaration.
98819880 const clang::Module *declSubmodule = *getClangSubmoduleForDecl (decl);
98829881 auto extensionKey = std::make_pair (nominal, declSubmodule);
9883- auto knownExtension = extensionPoints.find (extensionKey);
9884- if (knownExtension != extensionPoints. end () )
9885- return knownExtension-> second ;
9882+ auto [it, inserted] = extensionPoints.try_emplace (extensionKey, nullptr );
9883+ if (!inserted )
9884+ return it-> getSecond () ;
98869885
98879886 // Create a new extension for this nominal type/Clang submodule pair.
98889887 auto ext = ExtensionDecl::create (SwiftContext, SourceLoc (), nullptr , {},
@@ -9895,7 +9894,7 @@ ClangImporter::Implementation::importDeclContextOf(
98959894 // Record this extension so we can find it later. We do this early because
98969895 // once we've set the member loader, we don't know when the compiler will use
98979896 // it and end up back in this method.
9898- extensionPoints[extensionKey] = ext;
9897+ it-> getSecond () = ext;
98999898 ext->setMemberLoader (this , reinterpret_cast <uintptr_t >(declSubmodule));
99009899
99019900 if (auto protoDecl = ext->getExtendedProtocolDecl ()) {
0 commit comments