Skip to content

Commit 5aa005f

Browse files
authored
Merge pull request #4552 from Nirma/string_buffer_check
[stdlib] rewrite optional handling using map
2 parents 80f0044 + 0d2a204 commit 5aa005f

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

stdlib/public/core/String.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,7 @@ extension String {
321321
let (stringBufferOptional, _) =
322322
_StringBuffer.fromCodeUnits(input, encoding: encoding,
323323
repairIllFormedSequences: false)
324-
if let stringBuffer = stringBufferOptional {
325-
return String(_storage: stringBuffer)
326-
} else {
327-
return nil
328-
}
324+
return stringBufferOptional.map { String(_storage: $0) }
329325
}
330326

331327
public // @testable

0 commit comments

Comments
 (0)