Skip to content

Commit f97961a

Browse files
committed
[stdlib] fix _makeMutableAndUniqueUnchecked()
1 parent 1d5fecb commit f97961a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

stdlib/public/core/Array.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ extension Array {
356356
}
357357

358358
#if INTERNAL_CHECKS_ENABLED && COW_CHECKS_ENABLED
359-
@inlinable
359+
@_alwaysEmitIntoClient
360360
@_semantics("array.make_mutable")
361361
@_effects(notEscaping self.**)
362362
internal mutating func _makeMutableAndUniqueUnchecked() {

stdlib/public/core/ArraySlice.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ extension ArraySlice {
169169
}
170170
}
171171

172+
#if INTERNAL_CHECKS_ENABLED && COW_CHECKS_ENABLED
173+
@_alwaysEmitIntoClient
174+
@_semantics("array.make_mutable")
175+
internal mutating func _makeMutableAndUniqueUnchecked() {
176+
if _slowPath(!_buffer.beginCOWMutationUnchecked()) {
177+
_buffer = _Buffer(copying: _buffer)
178+
}
179+
}
180+
#endif
181+
172182
/// Marks the end of a mutation.
173183
///
174184
/// After a call to `_endMutation` the buffer must not be mutated until a call

stdlib/public/core/ContiguousArray.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ extension ContiguousArray {
7474
}
7575
}
7676

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+
7787
/// Marks the end of an Array mutation.
7888
///
7989
/// After a call to `_endMutation` the buffer must not be mutated until a call

0 commit comments

Comments
 (0)