@@ -74,6 +74,16 @@ extension ContiguousArray {
74
74
}
75
75
}
76
76
77
+ #if INTERNAL_CHECKS_ENABLED && COW_CHECKS_ENABLED
78
+ @_alwaysEmitIntoClient
79
+ @_semantics ( " array.make_mutable " )
80
+ internal mutating func _makeMutableAndUniqueUnchecked( ) {
81
+ if _slowPath ( !_buffer. beginCOWMutationUnchecked ( ) ) {
82
+ _buffer = _buffer. _consumeAndCreateNew ( )
83
+ }
84
+ }
85
+ #endif
86
+
77
87
/// Marks the end of an Array mutation.
78
88
///
79
89
/// After a call to `_endMutation` the buffer must not be mutated until a call
@@ -1151,19 +1161,24 @@ extension ContiguousArray {
1151
1161
) throws ( E) -> R {
1152
1162
return try unsafe _buffer. withUnsafeBufferPointer ( body)
1153
1163
}
1164
+ }
1154
1165
1155
- @available ( SwiftStdlib 6 . 2 , * )
1166
+ @available ( SwiftCompatibilitySpan 5 . 0 , * )
1167
+ @_originallyDefinedIn ( module: " Swift;CompatibilitySpan " , SwiftCompatibilitySpan 6 . 2 )
1168
+ extension ContiguousArray {
1169
+ @_alwaysEmitIntoClient
1156
1170
public var span : Span < Element > {
1157
1171
@lifetime ( borrow self)
1158
- @_alwaysEmitIntoClient
1159
1172
borrowing get {
1160
1173
let pointer = unsafe _buffer . firstElementAddress
1161
1174
let count = _buffer. immutableCount
1162
1175
let span = unsafe Span( _unsafeStart: pointer, count: count)
1163
1176
return unsafe _overrideLifetime ( span, borrowing: self )
1164
1177
}
1165
1178
}
1179
+ }
1166
1180
1181
+ extension ContiguousArray {
1167
1182
// Superseded by the typed-throws version of this function, but retained
1168
1183
// for ABI reasons.
1169
1184
@_semantics ( " array.withUnsafeMutableBufferPointer " )
@@ -1241,8 +1256,11 @@ extension ContiguousArray {
1241
1256
// Invoke the body.
1242
1257
return try unsafe body( & inoutBufferPointer)
1243
1258
}
1259
+ }
1244
1260
1245
- @available ( SwiftStdlib 6 . 2 , * )
1261
+ @available ( SwiftCompatibilitySpan 5 . 0 , * )
1262
+ @_originallyDefinedIn ( module: " Swift;CompatibilitySpan " , SwiftCompatibilitySpan 6 . 2 )
1263
+ extension ContiguousArray {
1246
1264
@_alwaysEmitIntoClient
1247
1265
public var mutableSpan : MutableSpan < Element > {
1248
1266
@lifetime ( & self )
@@ -1262,7 +1280,9 @@ extension ContiguousArray {
1262
1280
return unsafe _override Lifetime ( span, mutating: & self )
1263
1281
}
1264
1282
}
1283
+ }
1265
1284
1285
+ extension ContiguousArray {
1266
1286
@inlinable
1267
1287
public __consuming func _copyContents(
1268
1288
initializing buffer: UnsafeMutableBufferPointer < Element >
0 commit comments