Skip to content

Commit 2086313

Browse files
committed
[stdlib] Work around the optimizer helpfully reintroducing retain/releases
This is just wild flailing at this point, but it does seem to get us more plausible assembly.
1 parent cf1b9d9 commit 2086313

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

stdlib/public/core/StringGutsRangeReplaceable.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,29 @@
1313
// COW helpers
1414
extension _StringGuts {
1515
internal var nativeCapacity: Int? {
16-
guard hasNativeStorage else { return nil }
17-
return _object.withNativeStorage { $0.capacity }
16+
@inline(never)
17+
@_effects(releasenone)
18+
get {
19+
guard hasNativeStorage else { return nil }
20+
return _object.withNativeStorage { $0.capacity }
21+
}
1822
}
1923

2024
internal var nativeUnusedCapacity: Int? {
21-
guard hasNativeStorage else { return nil }
22-
return _object.withNativeStorage { $0.unusedCapacity }
25+
@inline(never)
26+
@_effects(releasenone)
27+
get {
28+
guard hasNativeStorage else { return nil }
29+
return _object.withNativeStorage { $0.unusedCapacity }
30+
}
2331
}
2432

2533
// If natively stored and uniquely referenced, return the storage's total
2634
// capacity. Otherwise, nil.
2735
internal var uniqueNativeCapacity: Int? {
28-
@inline(__always) mutating get {
36+
@inline(never)
37+
@_effects(releasenone)
38+
mutating get {
2939
guard isUniqueNative else { return nil }
3040
return _object.withNativeStorage { $0.capacity }
3141
}
@@ -34,7 +44,9 @@ extension _StringGuts {
3444
// If natively stored and uniquely referenced, return the storage's spare
3545
// capacity. Otherwise, nil.
3646
internal var uniqueNativeUnusedCapacity: Int? {
37-
@inline(__always) mutating get {
47+
@inline(never)
48+
@_effects(releasenone)
49+
mutating get {
3850
guard isUniqueNative else { return nil }
3951
return _object.withNativeStorage { $0.unusedCapacity }
4052
}

0 commit comments

Comments
 (0)