Skip to content

Commit 2fbb67a

Browse files
committed
Don't memoize the bridging witness for Dictionary
We know this memoization makes a big difference for String, but the wins for Dictionary are less clear. It's easy to add it back later if it proves helpful.
1 parent 3b23ced commit 2fbb67a

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

stdlib/public/runtime/DynamicCast.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -750,18 +750,6 @@ tryCastToDictionary(
750750
assert(destStructType->Description == &NOMINAL_TYPE_DESCR_SYM(SD));
751751

752752
switch (srcType->getKind()) {
753-
case MetadataKind::ForeignClass: // CF -> String
754-
case MetadataKind::ObjCClassWrapper: { // Obj-C -> String
755-
#if SWIFT_OBJC_INTEROP
756-
static ObjCBridgeMemo memo;
757-
758-
return memo.tryBridge(
759-
destLocation, destType, srcValue, srcType,
760-
destFailureType, srcFailureType,
761-
takeOnSuccess, mayDeferChecks);
762-
#endif
763-
}
764-
765753
case MetadataKind::Struct: { // Struct -> Dictionary
766754
const auto srcStructType = cast<StructMetadata>(srcType);
767755
if (srcStructType->Description == &NOMINAL_TYPE_DESCR_SYM(SD)) { // Dictionary -> Dictionary
@@ -871,7 +859,11 @@ tryCastToStruct(
871859
assert(srcType != destType);
872860
assert(destType->getKind() == MetadataKind::Struct);
873861

874-
// Struct has no special cast handling at present.
862+
// There is no special cast handling at present for general Struct types.
863+
864+
// Special logic for AnyHashable, Set, Dictionary, Array, and String
865+
// is broken out above. See also selectCasterForDest() for the
866+
// logic that chooses one of these functions.
875867

876868
return DynamicCastResult::Failure;
877869
}

0 commit comments

Comments
 (0)