@@ -306,8 +306,7 @@ extension Slice: RangeReplaceableCollection
306
306
@_inlineable // FIXME(sil-serialize-all)
307
307
public mutating func insert( _ newElement: Base . Element , at i: Index ) {
308
308
// FIXME: swift-3-indexing-model: range check.
309
- let sliceOffset =
310
- _base. distance ( from: _base. startIndex, to: _startIndex)
309
+ let sliceOffset = _base. distance ( from: _base. startIndex, to: _startIndex)
311
310
let newSliceCount = count + 1
312
311
_base. insert ( newElement, at: i)
313
312
_startIndex = _base. index ( _base. startIndex, offsetBy: sliceOffset)
@@ -358,7 +357,7 @@ extension Slice
358
357
) where C : Collection , C. Element == Base . Element {
359
358
// FIXME: swift-3-indexing-model: range check.
360
359
if subRange. lowerBound == _base. startIndex {
361
- let newSliceCount : Int =
360
+ let newSliceCount =
362
361
_base. distance ( from: _startIndex, to: subRange. lowerBound)
363
362
+ _base. distance ( from: subRange. upperBound, to: _endIndex)
364
363
+ ( numericCast ( newElements. count) as Int )
@@ -383,7 +382,7 @@ extension Slice
383
382
public mutating func insert( _ newElement: Base . Element , at i: Index ) {
384
383
// FIXME: swift-3-indexing-model: range check.
385
384
if i == _base. startIndex {
386
- let newSliceCount : Int = count + 1
385
+ let newSliceCount = count + 1
387
386
_base. insert ( newElement, at: i)
388
387
_startIndex = _base. startIndex
389
388
_endIndex = _base. index ( _startIndex, offsetBy: newSliceCount)
@@ -404,8 +403,7 @@ extension Slice
404
403
where S : Collection , S. Element == Base . Element {
405
404
// FIXME: swift-3-indexing-model: range check.
406
405
if i == _base. startIndex {
407
- let newSliceCount : Int =
408
- count + ( numericCast ( newElements. count) as Int )
406
+ let newSliceCount = count + numericCast( newElements. count)
409
407
_base. insert ( contentsOf: newElements, at: i)
410
408
_startIndex = _base. startIndex
411
409
_endIndex = _base. index ( _startIndex, offsetBy: newSliceCount)
@@ -414,7 +412,7 @@ extension Slice
414
412
let lastValidIndex = _base. index ( before: i)
415
413
let newEndIndexOffset =
416
414
_base. distance ( from: i, to: _endIndex)
417
- + ( numericCast ( newElements. count) as Int ) + 1
415
+ + numericCast( newElements. count) + 1
418
416
_base. insert ( contentsOf: newElements, at: i)
419
417
if shouldUpdateStartIndex {
420
418
_startIndex = _base. index ( after: lastValidIndex)
@@ -427,7 +425,7 @@ extension Slice
427
425
public mutating func remove( at i: Index ) -> Base . Element {
428
426
// FIXME: swift-3-indexing-model: range check.
429
427
if i == _base. startIndex {
430
- let newSliceCount : Int = count - 1
428
+ let newSliceCount = count - 1
431
429
let result = _base. remove ( at: i)
432
430
_startIndex = _base. startIndex
433
431
_endIndex = _base. index ( _startIndex, offsetBy: newSliceCount)
@@ -449,17 +447,16 @@ extension Slice
449
447
public mutating func removeSubrange( _ bounds: Range < Index > ) {
450
448
// FIXME: swift-3-indexing-model: range check.
451
449
if bounds. lowerBound == _base. startIndex {
452
- let newSliceCount : Int =
453
- count
454
- - _base. distance ( from: bounds. lowerBound, to: bounds. upperBound)
450
+ let newSliceCount =
451
+ count - _base. distance ( from: bounds. lowerBound, to: bounds. upperBound)
455
452
_base. removeSubrange ( bounds)
456
453
_startIndex = _base. startIndex
457
454
_endIndex = _base. index ( _startIndex, offsetBy: newSliceCount)
458
455
} else {
459
456
let shouldUpdateStartIndex = bounds. lowerBound == _startIndex
460
457
let lastValidIndex = _base. index ( before: bounds. lowerBound)
461
- let newEndIndexOffset : Int =
462
- _base. distance ( from: bounds. lowerBound, to: _endIndex)
458
+ let newEndIndexOffset =
459
+ _base. distance ( from: bounds. lowerBound, to: _endIndex)
463
460
- _base. distance ( from: bounds. lowerBound, to: bounds. upperBound)
464
461
+ 1
465
462
_base. removeSubrange ( bounds)
0 commit comments