File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,15 @@ extension _SmallString {
93
93
#endif
94
94
}
95
95
96
+ @_alwaysEmitIntoClient @inline ( __always)
97
+ internal static var contiguousCapacity : Int {
98
+ #if _pointerBitWidth(_32) && os(watchOS)
99
+ return capacity &- 2
100
+ #else
101
+ return capacity
102
+ #endif
103
+ }
104
+
96
105
// Get an integer equivalent to the _StringObject.discriminatedObjectRawBits
97
106
// computed property.
98
107
@inlinable @inline ( __always)
Original file line number Diff line number Diff line change @@ -409,7 +409,7 @@ extension String.UTF8View {
409
409
public var _span : Span < UTF8 . CodeUnit > ? {
410
410
@lifetime ( borrow self)
411
411
borrowing get {
412
- if _guts. isSmall && _guts. count > ( _SmallString. capacity &- 2 ) {
412
+ if _guts. isSmall, _guts. count > _SmallString. contiguousCapacity {
413
413
return nil
414
414
}
415
415
return _underlyingSpan ( )
Original file line number Diff line number Diff line change @@ -871,7 +871,7 @@ extension Substring.UTF8View {
871
871
public var _span : Span < UTF8 . CodeUnit > ? {
872
872
@lifetime ( borrow self)
873
873
borrowing get {
874
- if _wholeGuts. isSmall && _wholeGuts. count > ( _SmallString. capacity &- 2 ) {
874
+ if _wholeGuts. isSmall, _wholeGuts. count > _SmallString. contiguousCapacity {
875
875
// substring is spannable only when the whole string is spannable.
876
876
return nil
877
877
}
Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ extension String {
291
291
public var _utf8Span : UTF8Span ? {
292
292
@lifetime ( borrow self)
293
293
borrowing get {
294
- if _guts. isSmall && _guts. count > ( _SmallString. capacity &- 2 ) {
294
+ if _guts. isSmall, _guts. count > _SmallString. contiguousCapacity {
295
295
return nil
296
296
}
297
297
return unsafe UTF8 Span(
@@ -426,7 +426,7 @@ extension Substring {
426
426
public var _utf8Span : UTF8Span ? {
427
427
@lifetime ( borrow self)
428
428
borrowing get {
429
- if _wholeGuts. isSmall && _wholeGuts. count > ( _SmallString. capacity &- 2 ) {
429
+ if _wholeGuts. isSmall, _wholeGuts. count > _SmallString. contiguousCapacity {
430
430
// substring is spannable only when the whole string is spannable.
431
431
return nil
432
432
}
You can’t perform that action at this time.
0 commit comments