@@ -14,16 +14,8 @@ import SwiftShims
1414
1515#if INTERNAL_CHECKS_ENABLED
1616@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
2719#endif
2820
2921/// Class used whose sole instance is used as storage for empty
@@ -468,34 +460,40 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {
468460 @_alwaysEmitIntoClient
469461 internal var isImmutable : Bool {
470462 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+ }
473467 }
474468 return true
475469 }
476470 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 " )
483485 }
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 " )
490486 }
491487 }
492488 }
493489 }
494490
495491 @_alwaysEmitIntoClient
496492 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+ }
499497 }
500498 return true
501499 }
0 commit comments