Skip to content

Commit 7dd70d2

Browse files
committed
Remove a handful of no-longer-needed explicit types
1 parent 5281ffb commit 7dd70d2

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

stdlib/public/core/BidirectionalCollection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,17 @@ extension BidirectionalCollection {
178178
@_inlineable // FIXME(sil-serialize-all)
179179
public func distance(from start: Index, to end: Index) -> Int {
180180
var start = start
181-
var count: Int = 0
181+
var count = 0
182182

183183
if start < end {
184184
while start != end {
185-
count += 1 as Int
185+
count += 1
186186
formIndex(after: &start)
187187
}
188188
}
189189
else if start > end {
190190
while start != end {
191-
count -= 1 as Int
191+
count -= 1
192192
formIndex(before: &start)
193193
}
194194
}

stdlib/public/core/Collection.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,7 @@ public protocol Collection: Sequence where SubSequence: Collection {
401401
/// This associated type appears as a requirement in the `Sequence`
402402
/// protocol, but it is restated here with stricter constraints. In a
403403
/// collection, the subsequence should also conform to `Collection`.
404-
associatedtype SubSequence = Slice<Self>
405-
where SubSequence.Index == Index
404+
associatedtype SubSequence = Slice<Self> where SubSequence.Index == Index
406405

407406
/// Accesses the element at the specified position.
408407
///

stdlib/public/core/Indices.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension DefaultIndices: Collection {
3939
public typealias Element = Elements.Index
4040
public typealias Indices = DefaultIndices<Elements>
4141
public typealias SubSequence = DefaultIndices<Elements>
42-
public typealias Iterator = IndexingIterator<DefaultIndices<Elements>>
42+
public typealias Iterator = IndexingIterator<DefaultIndices<Elements>>
4343

4444
@_inlineable
4545
public var startIndex: Index {

stdlib/public/core/Slice.swift

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,7 @@ extension Slice: RangeReplaceableCollection
306306
@_inlineable // FIXME(sil-serialize-all)
307307
public mutating func insert(_ newElement: Base.Element, at i: Index) {
308308
// 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)
311310
let newSliceCount = count + 1
312311
_base.insert(newElement, at: i)
313312
_startIndex = _base.index(_base.startIndex, offsetBy: sliceOffset)
@@ -358,7 +357,7 @@ extension Slice
358357
) where C : Collection, C.Element == Base.Element {
359358
// FIXME: swift-3-indexing-model: range check.
360359
if subRange.lowerBound == _base.startIndex {
361-
let newSliceCount: Int =
360+
let newSliceCount =
362361
_base.distance(from: _startIndex, to: subRange.lowerBound)
363362
+ _base.distance(from: subRange.upperBound, to: _endIndex)
364363
+ (numericCast(newElements.count) as Int)
@@ -383,7 +382,7 @@ extension Slice
383382
public mutating func insert(_ newElement: Base.Element, at i: Index) {
384383
// FIXME: swift-3-indexing-model: range check.
385384
if i == _base.startIndex {
386-
let newSliceCount: Int = count + 1
385+
let newSliceCount = count + 1
387386
_base.insert(newElement, at: i)
388387
_startIndex = _base.startIndex
389388
_endIndex = _base.index(_startIndex, offsetBy: newSliceCount)
@@ -404,8 +403,7 @@ extension Slice
404403
where S : Collection, S.Element == Base.Element {
405404
// FIXME: swift-3-indexing-model: range check.
406405
if i == _base.startIndex {
407-
let newSliceCount: Int =
408-
count + (numericCast(newElements.count) as Int)
406+
let newSliceCount = count + numericCast(newElements.count)
409407
_base.insert(contentsOf: newElements, at: i)
410408
_startIndex = _base.startIndex
411409
_endIndex = _base.index(_startIndex, offsetBy: newSliceCount)
@@ -414,7 +412,7 @@ extension Slice
414412
let lastValidIndex = _base.index(before: i)
415413
let newEndIndexOffset =
416414
_base.distance(from: i, to: _endIndex)
417-
+ (numericCast(newElements.count) as Int) + 1
415+
+ numericCast(newElements.count) + 1
418416
_base.insert(contentsOf: newElements, at: i)
419417
if shouldUpdateStartIndex {
420418
_startIndex = _base.index(after: lastValidIndex)
@@ -427,7 +425,7 @@ extension Slice
427425
public mutating func remove(at i: Index) -> Base.Element {
428426
// FIXME: swift-3-indexing-model: range check.
429427
if i == _base.startIndex {
430-
let newSliceCount: Int = count - 1
428+
let newSliceCount = count - 1
431429
let result = _base.remove(at: i)
432430
_startIndex = _base.startIndex
433431
_endIndex = _base.index(_startIndex, offsetBy: newSliceCount)
@@ -449,17 +447,16 @@ extension Slice
449447
public mutating func removeSubrange(_ bounds: Range<Index>) {
450448
// FIXME: swift-3-indexing-model: range check.
451449
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)
455452
_base.removeSubrange(bounds)
456453
_startIndex = _base.startIndex
457454
_endIndex = _base.index(_startIndex, offsetBy: newSliceCount)
458455
} else {
459456
let shouldUpdateStartIndex = bounds.lowerBound == _startIndex
460457
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)
463460
- _base.distance(from: bounds.lowerBound, to: bounds.upperBound)
464461
+ 1
465462
_base.removeSubrange(bounds)

stdlib/public/core/StringUTF8.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ extension String {
284284
@_versioned
285285
@inline(__always)
286286
internal func _forwardDistance(from i: Index, to j: Index) -> Int {
287-
var r: Int = j._transcodedOffset - i._transcodedOffset
287+
var r = j._transcodedOffset - i._transcodedOffset
288288
UTF8._transcode(
289289
_core[i.encodedOffset..<j.encodedOffset], from: UTF16.self) {
290290
r += $0.count

0 commit comments

Comments
 (0)