File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change @@ -305,20 +305,15 @@ extension String {
305305 _ input: UnsafeBufferPointer < Encoding . CodeUnit > ,
306306 as encoding: Encoding . Type
307307 ) -> String ? {
308- fast: // fast-path
309308 if encoding. CodeUnit. self == UInt8 . self {
310309 let bytes = _identityCast ( input, to: UnsafeBufferPointer< UInt8> . self )
311- let isASCII : Bool
312310 if encoding. self == UTF8 . self {
313311 guard case . success( let info) = validateUTF8 ( bytes) else { return nil }
314- isASCII = info. isASCII
312+ return String . _uncheckedFromUTF8 ( bytes , asciiPreScanResult : info. isASCII)
315313 } else if encoding. self == Unicode . ASCII. self {
316314 guard _allASCII ( bytes) else { return nil }
317- isASCII = true
318- } else {
319- break fast
315+ return String . _uncheckedFromASCII ( bytes)
320316 }
321- return String . _uncheckedFromUTF8 ( bytes, asciiPreScanResult: isASCII)
322317 }
323318
324319 // slow-path
You can’t perform that action at this time.
0 commit comments