File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ extension String.UTF8View {
337337 borrowing get {
338338#if _runtime(_ObjC)
339339 // handle non-UTF8 Objective-C bridging cases here
340- if !_guts. isFastUTF8 && _guts. _object. hasObjCBridgeableObject {
340+ if !_guts. isFastUTF8, _guts. _object. hasObjCBridgeableObject {
341341 let storage = _guts. _getOrAllocateAssociatedStorage ( )
342342 let ( start, count) = unsafe ( storage. start, storage. count)
343343 let span = unsafe Span( _unsafeStart: start, count: count)
@@ -351,9 +351,9 @@ extension String.UTF8View {
351351 let span = unsafe Span( _unsafeStart: address, count: count)
352352 return unsafe _override Lifetime ( span, borrowing: self )
353353 }
354- _precondition ( _guts. isFastUTF8)
354+ let isFastUTF8 = _guts. isFastUTF8
355+ _precondition ( isFastUTF8, " String must be contiguous UTF8 " )
355356 let buffer = unsafe _guts. _object . fastUTF8
356- _precondition ( count == buffer. count)
357357 let span = unsafe Span( _unsafeElements: buffer)
358358 return unsafe _override Lifetime ( span, borrowing: self )
359359 }
Original file line number Diff line number Diff line change @@ -779,7 +779,7 @@ extension Substring.UTF8View {
779779 borrowing get {
780780#if _runtime(_ObjC)
781781 // handle non-UTF8 Objective-C bridging cases here
782- if !_wholeGuts. isFastUTF8 && _wholeGuts. _object. hasObjCBridgeableObject {
782+ if !_wholeGuts. isFastUTF8, _wholeGuts. _object. hasObjCBridgeableObject {
783783 let base : String . UTF8View = self . _base
784784 let first = base. _foreignDistance ( from: base. startIndex, to: startIndex)
785785 let count = base. _foreignDistance ( from: startIndex, to: endIndex)
@@ -796,7 +796,8 @@ extension Substring.UTF8View {
796796 let span = unsafe Span( _unsafeStart: start, count: end &- first)
797797 return unsafe _override Lifetime ( span, borrowing: self )
798798 }
799- _precondition ( _wholeGuts. isFastUTF8)
799+ let isFastUTF8 = _wholeGuts. isFastUTF8
800+ _precondition ( isFastUTF8, " Substring must be contiguous UTF8 " )
800801 var span = unsafe Span( _unsafeElements: _wholeGuts. _object. fastUTF8)
801802 span = span. _extracting ( first..< end)
802803 return unsafe _override Lifetime ( span, borrowing: self )
You can’t perform that action at this time.
0 commit comments