NSStringFromClass optimized: replaced String(reflecting:) with _typeName#5402
NSStringFromClass optimized: replaced String(reflecting:) with _typeName#5402ChrisBenua wants to merge 1 commit into
NSStringFromClass optimized: replaced String(reflecting:) with _typeName#5402Conversation
|
Can you define "much faster"? Have you measured the performance difference? Do you have any metrics to share? |
Jonathan, I've answered the same question in similar PR |
|
This seems like something that should be fixed within |
I haven’t attempted to modify String(reflecting/describing:) yet. I wonder what possible solutions there are. As for me, introducing new overloads for String(reflecting/describing:) with an argument of Any.Type should be fine. |
|
I think we should investigate that avenue more (fix this in the stdlib/runtime instead of fixing this in every library that calls this function). Fixing this in every library isn't tenable and if this is indeed a good fix let's make it at the best spot possible. That way it doesn't leave unclear usages of underscored APIs in a variety of projects |
NSStringFromClassoptimized by replacingString(reflecting:)with_typeNameMotivation:
Optimizing
NSStringFromClass.Modifications:
I've replaced heavy
String(reflecting:)call with_typeNamefunction. It's valid becauseString(reflecting:)eventually calls_typeNamefunctionResult:
NSStringFromClasswill work much faster.Testing:
Tested locally. Basically, testing is not needed because calls are equivalent and there are unit-tests in
TestObjCRuntime.swift. The same change was made here: swiftlang/swift#77369