Commit 70e9b96
authored
[stdlib] Make Range.init(_: ClosedRange<Bound>) inlinable
Currently, a simple function such as:
```swift
func makeSingleElementRange(n: Int) -> Range<Int> {
return Range(n...n)
}
```
will result in the following assembly under optimisation:
```
output.makeSingleElementRange(n: Swift.Int) -> Swift.Range<Swift.Int>:
sub rsp, 40
mov qword ptr [rsp + 8], rdi
mov qword ptr [rsp + 16], rdi
call (lazy protocol witness table accessor for type Swift.Int and conformance Swift.Int : Swift.SignedInteger in Swift)
mov rcx, rax
mov rsi, qword ptr [rip + ($sSiN)@GOTPCREL]
mov rdx, qword ptr [rip + ($sSiSxsWP)@GOTPCREL]
lea rax, [rsp + 24]
lea rdi, [rsp + 8]
call ($sSnsSxRzSZ6StrideRpzrlEySnyxGSNyxGcfC)@plt
mov rax, qword ptr [rsp + 24]
mov rdx, qword ptr [rsp + 32]
add rsp, 40
ret
```
Mark the `init` as inlinable so these functions can be properly optimised.
Also add a missing line of documentation.1 parent 847b6c0 commit 70e9b96
1 file changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
| 319 | + | |
318 | 320 | | |
319 | 321 | | |
320 | 322 | | |
| |||
0 commit comments