File tree 2 files changed +6
-5
lines changed 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ extension String.UTF8View {
337
337
borrowing get {
338
338
#if _runtime(_ObjC)
339
339
// handle non-UTF8 Objective-C bridging cases here
340
- if !_guts. isFastUTF8 && _guts. _object. hasObjCBridgeableObject {
340
+ if !_guts. isFastUTF8, _guts. _object. hasObjCBridgeableObject {
341
341
let storage = _guts. _getOrAllocateAssociatedStorage ( )
342
342
let ( start, count) = unsafe ( storage. start, storage. count)
343
343
let span = unsafe Span( _unsafeStart: start, count: count)
@@ -351,9 +351,9 @@ extension String.UTF8View {
351
351
let span = unsafe Span( _unsafeStart: address, count: count)
352
352
return unsafe _override Lifetime ( span, borrowing: self )
353
353
}
354
- _precondition ( _guts. isFastUTF8)
354
+ let isFastUTF8 = _guts. isFastUTF8
355
+ _precondition ( isFastUTF8, " String must be contiguous UTF8 " )
355
356
let buffer = unsafe _guts. _object . fastUTF8
356
- _precondition ( count == buffer. count)
357
357
let span = unsafe Span( _unsafeElements: buffer)
358
358
return unsafe _override Lifetime ( span, borrowing: self )
359
359
}
Original file line number Diff line number Diff line change @@ -779,7 +779,7 @@ extension Substring.UTF8View {
779
779
borrowing get {
780
780
#if _runtime(_ObjC)
781
781
// handle non-UTF8 Objective-C bridging cases here
782
- if !_wholeGuts. isFastUTF8 && _wholeGuts. _object. hasObjCBridgeableObject {
782
+ if !_wholeGuts. isFastUTF8, _wholeGuts. _object. hasObjCBridgeableObject {
783
783
let base : String . UTF8View = self . _base
784
784
let first = base. _foreignDistance ( from: base. startIndex, to: startIndex)
785
785
let count = base. _foreignDistance ( from: startIndex, to: endIndex)
@@ -796,7 +796,8 @@ extension Substring.UTF8View {
796
796
let span = unsafe Span( _unsafeStart: start, count: end &- first)
797
797
return unsafe _override Lifetime ( span, borrowing: self )
798
798
}
799
- _precondition ( _wholeGuts. isFastUTF8)
799
+ let isFastUTF8 = _wholeGuts. isFastUTF8
800
+ _precondition ( isFastUTF8, " Substring must be contiguous UTF8 " )
800
801
var span = unsafe Span( _unsafeElements: _wholeGuts. _object. fastUTF8)
801
802
span = span. _extracting ( first..< end)
802
803
return unsafe _override Lifetime ( span, borrowing: self )
You can’t perform that action at this time.
0 commit comments