@@ -208,17 +208,14 @@ extension Substring: StringProtocol {
208
208
// not fall on grapheme boundaries in `base`.
209
209
210
210
let i = _wholeGuts. validateCharacterIndex ( i, in: _bounds)
211
- let r = _uncheckedIndex ( after: i)
212
- return _wholeGuts. markEncoding ( r)
211
+ return _uncheckedIndex ( after: i)
213
212
}
214
213
215
214
/// A version of `index(after:)` that assumes that the given index:
216
215
///
217
216
/// - has the right encoding,
218
217
/// - is within bounds, and
219
218
/// - is character aligned within this substring.
220
- ///
221
- /// It does not mark the encoding of the returned index.
222
219
internal func _uncheckedIndex( after i: Index ) -> Index {
223
220
_internalInvariant ( _wholeGuts. hasMatchingEncoding ( i) )
224
221
_internalInvariant ( i. _isScalarAligned)
@@ -252,7 +249,7 @@ extension Substring: StringProtocol {
252
249
r = r. _characterAligned
253
250
}
254
251
255
- return r
252
+ return _wholeGuts . markEncoding ( r )
256
253
}
257
254
258
255
public func index( before i: Index ) -> Index {
@@ -269,17 +266,14 @@ extension Substring: StringProtocol {
269
266
// alignment/validation work.
270
267
_precondition ( i > startIndex, " Substring index is out of bounds " )
271
268
272
- let r = _uncheckedIndex ( before: i)
273
- return _wholeGuts. markEncoding ( r)
269
+ return _uncheckedIndex ( before: i)
274
270
}
275
271
276
272
/// A version of `index(before:)` that assumes that the given index:
277
273
///
278
274
/// - has the right encoding,
279
275
/// - is within bounds, and
280
276
/// - is character aligned within this substring.
281
- ///
282
- /// It does not mark the encoding of the returned index.
283
277
internal func _uncheckedIndex( before i: Index ) -> Index {
284
278
_internalInvariant ( _wholeGuts. hasMatchingEncoding ( i) )
285
279
_internalInvariant ( i. _isScalarAligned)
@@ -304,7 +298,7 @@ extension Substring: StringProtocol {
304
298
r = r. _characterAligned
305
299
}
306
300
307
- return r
301
+ return _wholeGuts . markEncoding ( r )
308
302
}
309
303
310
304
public func index( _ i: Index , offsetBy distance: Int ) -> Index {
@@ -328,7 +322,7 @@ extension Substring: StringProtocol {
328
322
i = _uncheckedIndex ( before: i)
329
323
}
330
324
}
331
- return _wholeGuts . markEncoding ( i )
325
+ return i
332
326
}
333
327
334
328
public func index(
@@ -368,7 +362,7 @@ extension Substring: StringProtocol {
368
362
}
369
363
guard limit > start || i >= limit else { return nil }
370
364
}
371
- return _wholeGuts . markEncoding ( i )
365
+ return i
372
366
}
373
367
374
368
public func distance( from start: Index , to end: Index ) -> Int {
0 commit comments