mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user