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 {
305
305
_ input: UnsafeBufferPointer < Encoding . CodeUnit > ,
306
306
as encoding: Encoding . Type
307
307
) -> String ? {
308
- fast: // fast-path
309
308
if encoding. CodeUnit. self == UInt8 . self {
310
309
let bytes = _identityCast ( input, to: UnsafeBufferPointer< UInt8> . self )
311
- let isASCII : Bool
312
310
if encoding. self == UTF8 . self {
313
311
guard case . success( let info) = validateUTF8 ( bytes) else { return nil }
314
- isASCII = info. isASCII
312
+ return String . _uncheckedFromUTF8 ( bytes , asciiPreScanResult : info. isASCII)
315
313
} else if encoding. self == Unicode . ASCII. self {
316
314
guard _allASCII ( bytes) else { return nil }
317
- isASCII = true
318
- } else {
319
- break fast
315
+ return String . _uncheckedFromASCII ( bytes)
320
316
}
321
- return String . _uncheckedFromUTF8 ( bytes, asciiPreScanResult: isASCII)
322
317
}
323
318
324
319
// slow-path
You can’t perform that action at this time.
0 commit comments