-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Previous ID | SR-11158 |
Radar | rdar://problem/53285593 |
Original Reporter | @jckarter |
Type | Task |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Task, Optimizer, Performance |
Assignee | None |
Priority | Medium |
md5: ff5022700bfbd3677810f44a7efffaae
Issue Description:
In https://forums.swift.org/t/performance-overhead-for-protocols/27104/6, a generic function is slower after generic specialization than the equivalent concrete function, because the generic function still uses the fully dynamic string interpolation entry point instead of one of the specific entry points. In a reduced example:
func foo<T: FloatingPoint>(x: T) -> String { return "\(x)" }
func bar(x: Double) -> String { return "\(x)" }
bar
uses the appendInterpolation<T: TextOutputStreamable>
implementation, and foo
uses the fully generic implementation, even if we later specialize foo
for T == Double
. Since we know the behavior of the fully generic appendInterpolation
implementation, we could conceivably re-specialize calls into it if we later specialize a call to a type that we know statically conforms to one of the customization protocols.