Skip to content

Commit 6e6aae8

Browse files
committed
Mark all _unconditionallyBridgeFromObjectiveC functions as @_effects(readonly)
This enables removal of those bridging calls for dead parameters. Read-only lets the optimizer remove such a call if the result is not used. Note that "readonly" means: no observable write operations. It's okay to allocate and initialize new objects. rdar://problem/44944094
1 parent 73aabff commit 6e6aae8

32 files changed

+68
-2
lines changed

stdlib/public/SDK/Dispatch/Data.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ extension DispatchData {
356356
return true
357357
}
358358

359+
@_effects(readonly)
359360
public static func _unconditionallyBridgeFromObjectiveC(_ source: __DispatchData?) -> DispatchData {
360361
var result: DispatchData?
361362
_forceBridgeFromObjectiveC(source!, result: &result)

stdlib/public/SDK/Foundation/AffineTransform.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ extension AffineTransform : _ObjectiveCBridgeable {
317317
return true // Can't fail
318318
}
319319

320+
@_effects(readonly)
320321
public static func _unconditionallyBridgeFromObjectiveC(_ x: NSAffineTransform?) -> AffineTransform {
321322
guard let src = x else { return AffineTransform.identity }
322323
return AffineTransform(reference: src)

stdlib/public/SDK/Foundation/Calendar.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,7 @@ extension Calendar : _ObjectiveCBridgeable {
11131113
return true
11141114
}
11151115

1116+
@_effects(readonly)
11161117
public static func _unconditionallyBridgeFromObjectiveC(_ source: NSCalendar?) -> Calendar {
11171118
var result: Calendar?
11181119
_forceBridgeFromObjectiveC(source!, result: &result)

stdlib/public/SDK/Foundation/CharacterSet.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ extension CharacterSet : _ObjectiveCBridgeable {
782782
return true
783783
}
784784

785+
@_effects(readonly)
785786
public static func _unconditionallyBridgeFromObjectiveC(_ source: NSCharacterSet?) -> CharacterSet {
786787
guard let src = source else { return CharacterSet() }
787788
return CharacterSet(_bridged: src)

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1902,7 +1902,8 @@ extension Data : _ObjectiveCBridgeable {
19021902
result = Data(referencing: input)
19031903
return true
19041904
}
1905-
1905+
1906+
@_effects(readonly)
19061907
public static func _unconditionallyBridgeFromObjectiveC(_ source: NSData?) -> Data {
19071908
guard let src = source else { return Data() }
19081909
return Data(referencing: src)

stdlib/public/SDK/Foundation/Date.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ extension Date : _ObjectiveCBridgeable {
257257
return true
258258
}
259259

260+
@_effects(readonly)
260261
public static func _unconditionallyBridgeFromObjectiveC(_ source: NSDate?) -> Date {
261262
var result: Date?
262263
_forceBridgeFromObjectiveC(source!, result: &result)

stdlib/public/SDK/Foundation/DateComponents.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ extension DateComponents : _ObjectiveCBridgeable {
338338
return true
339339
}
340340

341+
@_effects(readonly)
341342
public static func _unconditionallyBridgeFromObjectiveC(_ source: NSDateComponents?) -> DateComponents {
342343
guard let src = source else { return DateComponents() }
343344
return DateComponents(reference: src)

stdlib/public/SDK/Foundation/DateInterval.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ extension DateInterval : _ObjectiveCBridgeable {
216216
return true
217217
}
218218

219+
@_effects(readonly)
219220
public static func _unconditionallyBridgeFromObjectiveC(_ source: NSDateInterval?) -> DateInterval {
220221
var result: DateInterval?
221222
_forceBridgeFromObjectiveC(source!, result: &result)

stdlib/public/SDK/Foundation/Decimal.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ extension Decimal : _ObjectiveCBridgeable {
487487
return true
488488
}
489489

490+
@_effects(readonly)
490491
public static func _unconditionallyBridgeFromObjectiveC(_ source: NSDecimalNumber?) -> Decimal {
491492
guard let src = source else { return Decimal(_exponent: 0, _length: 0, _isNegative: 0, _isCompact: 0, _reserved: 0, _mantissa: (0, 0, 0, 0, 0, 0, 0, 0)) }
492493
return src.decimalValue

stdlib/public/SDK/Foundation/Foundation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ extension AnyHashable : _ObjectiveCBridgeable {
7373
return result != nil
7474
}
7575

76+
@_effects(readonly)
7677
public static func _unconditionallyBridgeFromObjectiveC(
7778
_ source: NSObject?
7879
) -> AnyHashable {

0 commit comments

Comments
 (0)