Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/public/core/ArrayBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extension _ArrayBuffer {

/// Puts the buffer in an immutable state.
///
/// - Precondition: The buffer must be mutable.
/// - Precondition: The buffer must be mutable or the empty array singleton.
///
/// - Warning: After a call to `endCOWMutation` the buffer must not be mutated
/// until the next call of `beginCOWMutation`.
Expand Down
19 changes: 9 additions & 10 deletions stdlib/public/core/ContiguousArrayBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -470,18 +470,17 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {
nonmutating set {
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
if (_COWChecksEnabled()) {
if newValue {
if capacity > 0 {
let wasImmutable = _swift_setImmutableCOWBuffer(_storage, true)
// Make sure to not modify the empty array singleton (which has a
// capacity of 0).
if capacity > 0 {
let wasImmutable = _swift_setImmutableCOWBuffer(_storage, newValue)
if newValue {
_internalInvariant(!wasImmutable,
"re-setting immutable array buffer to immutable")
} else {
_internalInvariant(wasImmutable,
"re-setting mutable array buffer to mutable")
}
} else {
_internalInvariant(capacity > 0,
"setting empty array buffer to mutable")
let wasImmutable = _swift_setImmutableCOWBuffer(_storage, false)
_internalInvariant(wasImmutable,
"re-setting mutable array buffer to mutable")
}
}
}
Expand Down Expand Up @@ -698,7 +697,7 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {

/// Puts the buffer in an immutable state.
///
/// - Precondition: The buffer must be mutable.
/// - Precondition: The buffer must be mutable or the empty array singleton.
///
/// - Warning: After a call to `endCOWMutation` the buffer must not be mutated
/// until the next call of `beginCOWMutation`.
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/SliceBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ internal struct _SliceBuffer<Element>

/// Puts the buffer in an immutable state.
///
/// - Precondition: The buffer must be mutable.
/// - Precondition: The buffer must be mutable or the empty array singleton.
///
/// - Warning: After a call to `endCOWMutation` the buffer must not be mutated
/// until the next call of `beginCOWMutation`.
Expand Down