Skip to content

Commit 92df9b4

Browse files
Apply suggestions from code review
Co-authored-by: Ben Rimmington <[email protected]>
1 parent 7648210 commit 92df9b4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

stdlib/public/core/String.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ extension String {
493493
self = String._fromNonContiguousUnsafeBitcastUTF8Repairing(codeUnits).0
494494
}
495495

496-
/// Creates a new `String` by copying and validating the sequence of
496+
/// Creates a new string by copying and validating the sequence of
497497
/// code units passed in, according to the specified encoding.
498498
///
499499
/// This initializer does not try to repair ill-formed code unit sequences.
@@ -553,8 +553,8 @@ extension String {
553553
}
554554
}
555555

556-
/// Creates a new `String` by copying and validating the sequence of
557-
/// `Int8` passed in, according to the specified encoding.
556+
/// Creates a new string by copying and validating the sequence of
557+
/// code units passed in, according to the specified encoding.
558558
///
559559
/// This initializer does not try to repair ill-formed code unit sequences.
560560
/// If any are found, the result of the initializer is `nil`.
@@ -596,9 +596,7 @@ extension String {
596596

597597
// slow-path
598598
let uint8s = codeUnits.lazy.map(UInt8.init(bitPattern:))
599-
let string = String(validating: uint8s, as: Encoding.self)
600-
guard let string else { return nil }
601-
self = string
599+
self.init(validating: uint8s, as: Encoding.self)
602600
}
603601

604602
/// Creates a new string with the specified capacity in UTF-8 code units, and

0 commit comments

Comments
 (0)