File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed
include/swift/RemoteInspection
stdlib/public/RemoteInspection Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -534,6 +534,12 @@ class TypeRefBuilder {
534534 // / Indexes of Reflection Infos we've already processed.
535535 llvm::DenseSet<size_t > ProcessedReflectionInfoIndexes;
536536
537+ // / Cache for capture descriptor lookups.
538+ std::unordered_map<uint64_t /* remote address*/ ,
539+ RemoteRef<CaptureDescriptor>>
540+ CaptureDescriptorsByAddress;
541+ uint32_t CaptureDescriptorsByAddressLastReflectionInfoCache = 0 ;
542+
537543 // / Cache for field info lookups.
538544 std::unordered_map<std::string, RemoteRef<FieldDescriptor>>
539545 FieldTypeInfoCache;
Original file line number Diff line number Diff line change @@ -684,15 +684,24 @@ TypeRefBuilder::getMultiPayloadEnumDescriptor(const TypeRef *TR) {
684684RemoteRef<CaptureDescriptor>
685685TypeRefBuilder::ReflectionTypeDescriptorFinder::getCaptureDescriptor (
686686 uint64_t RemoteAddress) {
687- for (auto Info : ReflectionInfos) {
688- for (auto CD : Info.Capture ) {
689- if (RemoteAddress == CD.getAddressData ()) {
690- return CD;
691- }
687+
688+ for (; CaptureDescriptorsByAddressLastReflectionInfoCache <
689+ ReflectionInfos.size ();
690+ CaptureDescriptorsByAddressLastReflectionInfoCache++) {
691+ for (const auto &CD :
692+ ReflectionInfos[CaptureDescriptorsByAddressLastReflectionInfoCache]
693+ .Capture ) {
694+ CaptureDescriptorsByAddress.emplace (
695+ std::make_pair (CD.getAddressData (), CD));
692696 }
693697 }
694698
695- return nullptr ;
699+ const auto found = CaptureDescriptorsByAddress.find (RemoteAddress);
700+ if (found == CaptureDescriptorsByAddress.end ()) {
701+ return nullptr ;
702+ }
703+
704+ return found->second ;
696705}
697706
698707// / Get the unsubstituted capture types for a closure context.
You can’t perform that action at this time.
0 commit comments