Component.name optimized: replace String(describing:) with _typeName#489
Open
ChrisBenua wants to merge 1 commit intouber:masterfrom
Open
Component.name optimized: replace String(describing:) with _typeName#489ChrisBenua wants to merge 1 commit intouber:masterfrom
Component.name optimized: replace String(describing:) with _typeName#489ChrisBenua wants to merge 1 commit intouber:masterfrom
Conversation
Author
|
@rudro Hi, Rudro! This PR will significantly improve performance for large apps. If this PR matches your expectations, I'd appreciate your guidance on how we can proceed with merging the PR. Thanks in advance! |
listrophy
reviewed
Jan 31, 2026
| let parts = fullyQualifiedSelfName.components(separatedBy: ".") | ||
| return parts.last ?? fullyQualifiedSelfName | ||
| }() | ||
| private lazy var name: String = _typeName(type(of: self), qualified: false) |
There was a problem hiding this comment.
This is wonderful, but it uses a private API. Up to the maintainers to decide if that's ok
Author
There was a problem hiding this comment.
It's not truly private API. This function is public but not documented.
Moreover, it can be accessed indirectly by calling regular string interpolation. Like "\(type(of: self))"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously,
String(describing: self)was used to get fully qualified name (including module name).But using
String(describing: self)to get type name is extremely ineffective (see #486 and swiftlang/swift#77369). In the endString(describing:)calls_typeName(:qualified:)function. Also, if we passqualified: false, we don't need to do any splitting workPrevious callstack when using
String(describing:):