[String.Index] Simplify and prepare for more resilience.

Simplify String.Index by sinking transcoded offsets into the .utf8
variant. This is in preparation for a more resilient index type
capable of supporting existential string indices.
This commit is contained in:
Michael Ilseman
2018-05-14 11:30:26 -07:00
parent ba65638244
commit 614016fecd
8 changed files with 217 additions and 154 deletions

View File

@@ -455,11 +455,8 @@ extension String {
@inlinable // FIXME(sil-serialize-all)
internal func _stride(of i: Index) -> Int {
if case .character(let stride) = i._cache {
// TODO: should _fastPath the case somehow
_sanityCheck(stride > 0)
return Int(stride)
}
if let stride = i.characterStride { return stride }
let offset = i.encodedOffset
return _visitGuts(_guts, args: offset,
ascii: { ascii, offset in