Skip to content

Commit 9c26ca4

Browse files
author
Lance Parker
committed
removed unimplemented() function, cleaned up the transcodeToUTF8 function
1 parent a0c7d11 commit 9c26ca4

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

stdlib/public/core/StringNormalization.swift

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ internal enum NormalizationResult {
136136
}
137137
}
138138

139-
func unimplemented() -> Never { fatalError("Unimplemented function called") }
140-
141139
internal func fastFill(
142140
_ sourceBuffer: UnsafeBufferPointer<UInt8>,
143141
_ outputBuffer: UnsafeMutableBufferPointer<UInt8>
@@ -234,18 +232,14 @@ internal func transcodeToUTF8(
234232
//a single segment at this point
235233

236234
readIndex += length
237-
guard scalar.withUTF8CodeUnits({ utf8 in
238-
for cu in utf8 {
239-
if writeIndex < outputCount {
240-
outputBuffer[writeIndex] = cu
241-
writeIndex += 1
242-
} else {
243-
return false
244-
}
235+
236+
for cu in UTF8.encode(scalar)._unsafelyUnwrappedUnchecked {
237+
if writeIndex < outputCount {
238+
outputBuffer[writeIndex] = cu
239+
writeIndex &+= 1
240+
} else {
241+
return nil
245242
}
246-
return true
247-
}) else {
248-
return nil
249243
}
250244
}
251245
return (readIndex, writeIndex)

0 commit comments

Comments
 (0)