Skip to content

Commit 32d1c22

Browse files
committed
[Runtime] Scan backwards within conformance sections when scanSectionsBackwards is true.
This more closely matches the previous behavior. rdar://73362732
1 parent 1d7d282 commit 32d1c22

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,10 @@ swift_conformsToProtocolImpl(const Metadata *const type,
472472
// Scan conformance records.
473473
auto processSection = [&](const ConformanceSection &section) {
474474
// Eagerly pull records for nondependent witnesses into our cache.
475-
for (const auto &record : section) {
476-
auto &descriptor = *record.get();
477-
475+
auto processDescriptor = [&](const ProtocolConformanceDescriptor &descriptor) {
478476
// We only care about conformances for this protocol.
479477
if (descriptor.getProtocol() != protocol)
480-
continue;
478+
return;
481479

482480
// If there's a matching type, record the positive result and return it.
483481
// The matching type is exact, so they can't go stale, and we should
@@ -487,6 +485,14 @@ swift_conformsToProtocolImpl(const Metadata *const type,
487485
auto witness = descriptor.getWitnessTable(matchingType);
488486
C.cacheResult(matchingType, protocol, witness, /*always cache*/ 0);
489487
}
488+
};
489+
490+
if (C.scanSectionsBackwards) {
491+
for (const auto &record : llvm::reverse(section))
492+
processDescriptor(*record.get());
493+
} else {
494+
for (const auto &record : section)
495+
processDescriptor(*record.get());
490496
}
491497
};
492498

0 commit comments

Comments
 (0)