@@ -14,16 +14,8 @@ import SwiftShims
14
14
15
15
#if INTERNAL_CHECKS_ENABLED
16
16
@available ( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * )
17
- @_silgen_name ( " swift_COWSanityChecksEnabled " )
18
- public func _COWSanityChecksEnabled( ) -> Bool
19
-
20
- @_alwaysEmitIntoClient
21
- internal func do COWSanityChecks( ) -> Bool {
22
- if #available( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * ) {
23
- return _COWSanityChecksEnabled ( )
24
- }
25
- return false
26
- }
17
+ @_silgen_name ( " swift_COWChecksEnabled " )
18
+ public func _COWChecksEnabled( ) -> Bool
27
19
#endif
28
20
29
21
/// Class used whose sole instance is used as storage for empty
@@ -468,34 +460,40 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {
468
460
@_alwaysEmitIntoClient
469
461
internal var isImmutable : Bool {
470
462
get {
471
- if doCOWSanityChecks ( ) {
472
- return capacity == 0 || _swift_isImmutableCOWBuffer ( _storage)
463
+ if #available( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * ) {
464
+ if ( _COWChecksEnabled ( ) ) {
465
+ return capacity == 0 || _swift_isImmutableCOWBuffer ( _storage)
466
+ }
473
467
}
474
468
return true
475
469
}
476
470
nonmutating set {
477
- if doCOWSanityChecks ( ) {
478
- if newValue {
479
- if capacity > 0 {
480
- let wasImmutable = _swift_setImmutableCOWBuffer ( _storage, true )
481
- _internalInvariant ( !wasImmutable,
482
- " re-setting immutable array buffer to immutable " )
471
+ if #available( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * ) {
472
+ if ( _COWChecksEnabled ( ) ) {
473
+ if newValue {
474
+ if capacity > 0 {
475
+ let wasImmutable = _swift_setImmutableCOWBuffer ( _storage, true )
476
+ _internalInvariant ( !wasImmutable,
477
+ " re-setting immutable array buffer to immutable " )
478
+ }
479
+ } else {
480
+ _internalInvariant ( capacity > 0 ,
481
+ " setting empty array buffer to mutable " )
482
+ let wasImmutable = _swift_setImmutableCOWBuffer ( _storage, false )
483
+ _internalInvariant ( wasImmutable,
484
+ " re-setting mutable array buffer to mutable " )
483
485
}
484
- } else {
485
- _internalInvariant ( capacity > 0 ,
486
- " setting empty array buffer to mutable " )
487
- let wasImmutable = _swift_setImmutableCOWBuffer ( _storage, false )
488
- _internalInvariant ( wasImmutable,
489
- " re-setting mutable array buffer to mutable " )
490
486
}
491
487
}
492
488
}
493
489
}
494
490
495
491
@_alwaysEmitIntoClient
496
492
internal var isMutable : Bool {
497
- if doCOWSanityChecks ( ) {
498
- return !_swift_isImmutableCOWBuffer( _storage)
493
+ if #available( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * ) {
494
+ if ( _COWChecksEnabled ( ) ) {
495
+ return !_swift_isImmutableCOWBuffer( _storage)
496
+ }
499
497
}
500
498
return true
501
499
}
0 commit comments