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 {
534
534
// / Indexes of Reflection Infos we've already processed.
535
535
llvm::DenseSet<size_t > ProcessedReflectionInfoIndexes;
536
536
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
+
537
543
// / Cache for field info lookups.
538
544
std::unordered_map<std::string, RemoteRef<FieldDescriptor>>
539
545
FieldTypeInfoCache;
Original file line number Diff line number Diff line change @@ -684,15 +684,24 @@ TypeRefBuilder::getMultiPayloadEnumDescriptor(const TypeRef *TR) {
684
684
RemoteRef<CaptureDescriptor>
685
685
TypeRefBuilder::ReflectionTypeDescriptorFinder::getCaptureDescriptor (
686
686
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));
692
696
}
693
697
}
694
698
695
- return nullptr ;
699
+ const auto found = CaptureDescriptorsByAddress.find (RemoteAddress);
700
+ if (found == CaptureDescriptorsByAddress.end ()) {
701
+ return nullptr ;
702
+ }
703
+
704
+ return found->second ;
696
705
}
697
706
698
707
// / Get the unsubstituted capture types for a closure context.
You can’t perform that action at this time.
0 commit comments