Skip to content

[5.4][Runtime] Scan backwards within conformance sections when scanSectionsBackwards is true. #35491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions stdlib/public/runtime/ProtocolConformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,10 @@ swift_conformsToProtocolImpl(const Metadata *const type,
// Scan conformance records.
auto processSection = [&](const ConformanceSection &section) {
// Eagerly pull records for nondependent witnesses into our cache.
for (const auto &record : section) {
auto &descriptor = *record.get();

auto processDescriptor = [&](const ProtocolConformanceDescriptor &descriptor) {
// We only care about conformances for this protocol.
if (descriptor.getProtocol() != protocol)
continue;
return;

// If there's a matching type, record the positive result and return it.
// The matching type is exact, so they can't go stale, and we should
Expand All @@ -487,6 +485,14 @@ swift_conformsToProtocolImpl(const Metadata *const type,
auto witness = descriptor.getWitnessTable(matchingType);
C.cacheResult(matchingType, protocol, witness, /*always cache*/ 0);
}
};

if (C.scanSectionsBackwards) {
for (const auto &record : llvm::reverse(section))
processDescriptor(*record.get());
} else {
for (const auto &record : section)
processDescriptor(*record.get());
}
};

Expand Down