[String] Cleanup normalization code.

Clean up some of the code surrounding the normalized code unit
iterator.
This commit is contained in:
Michael Ilseman
2018-09-24 11:42:59 -07:00
parent f1a35bd1c9
commit c51aa5988f
4 changed files with 62 additions and 164 deletions

View File

@@ -122,7 +122,7 @@ internal func _utf8ScalarLength(_ x: UInt8) -> Int {
@inlinable @inline(__always)
internal func _utf8ScalarLength(
_ utf8: UnsafeBufferPointer<UInt8>, endingAt i: Int
) -> Int {
) -> Int {
var len = 1
while _isContinuation(utf8[i &- len]) {
len += 1
@@ -385,11 +385,3 @@ extension String.Index {
return String.Index(encodedOffset: offset + 1)
}
}
extension UnsafeBufferPointer where Element == UInt8 {
@usableFromInline @inline(__always)
internal func _utf8ScalarLength(at index: Int) -> Int {
let x: UInt8 = self[index]
return Swift._utf8ScalarLength(x)
}
}