@@ -1150,7 +1150,7 @@ extension Collection {
1150
1150
@_inlineable
1151
1151
public var underestimatedCount : Int {
1152
1152
// TODO: swift-3-indexing-model - review the following
1153
- return numericCast ( count)
1153
+ return count
1154
1154
}
1155
1155
1156
1156
/// The number of elements in the collection.
@@ -1213,17 +1213,17 @@ extension Collection {
1213
1213
_ transform: ( Element ) throws -> T
1214
1214
) rethrows -> [ T ] {
1215
1215
// TODO: swift-3-indexing-model - review the following
1216
- let count : Int = numericCast ( self . count)
1217
- if count == 0 {
1216
+ let n = self . count
1217
+ if n == 0 {
1218
1218
return [ ]
1219
1219
}
1220
1220
1221
1221
var result = ContiguousArray < T > ( )
1222
- result. reserveCapacity ( count )
1222
+ result. reserveCapacity ( n )
1223
1223
1224
1224
var i = self . startIndex
1225
1225
1226
- for _ in 0 ..< count {
1226
+ for _ in 0 ..< n {
1227
1227
result. append ( try transform ( self [ i] ) )
1228
1228
formIndex ( after: & i)
1229
1229
}
@@ -1255,7 +1255,7 @@ extension Collection {
1255
1255
public func dropFirst( _ n: Int ) -> SubSequence {
1256
1256
_precondition ( n >= 0 , " Can't drop a negative number of elements from a collection " )
1257
1257
let start = index ( startIndex,
1258
- offsetBy: numericCast ( n ) , limitedBy: endIndex) ?? endIndex
1258
+ offsetBy: n , limitedBy: endIndex) ?? endIndex
1259
1259
return self [ start..< endIndex]
1260
1260
}
1261
1261
@@ -1281,9 +1281,9 @@ extension Collection {
1281
1281
public func dropLast( _ n: Int ) -> SubSequence {
1282
1282
_precondition (
1283
1283
n >= 0 , " Can't drop a negative number of elements from a collection " )
1284
- let amount = Swift . max ( 0 , numericCast ( count) - n)
1284
+ let amount = Swift . max ( 0 , count - n)
1285
1285
let end = index ( startIndex,
1286
- offsetBy: numericCast ( amount) , limitedBy: endIndex) ?? endIndex
1286
+ offsetBy: amount, limitedBy: endIndex) ?? endIndex
1287
1287
return self [ startIndex..< end]
1288
1288
}
1289
1289
@@ -1329,7 +1329,7 @@ extension Collection {
1329
1329
maxLength >= 0 ,
1330
1330
" Can't take a prefix of negative length from a collection " )
1331
1331
let end = index ( startIndex,
1332
- offsetBy: numericCast ( maxLength) , limitedBy: endIndex) ?? endIndex
1332
+ offsetBy: maxLength, limitedBy: endIndex) ?? endIndex
1333
1333
return self [ startIndex..< end]
1334
1334
}
1335
1335
@@ -1376,9 +1376,9 @@ extension Collection {
1376
1376
_precondition (
1377
1377
maxLength >= 0 ,
1378
1378
" Can't take a suffix of negative length from a collection " )
1379
- let amount = Swift . max ( 0 , numericCast ( count) - maxLength)
1379
+ let amount = Swift . max ( 0 , count - maxLength)
1380
1380
let start = index ( startIndex,
1381
- offsetBy: numericCast ( amount) , limitedBy: endIndex) ?? endIndex
1381
+ offsetBy: amount, limitedBy: endIndex) ?? endIndex
1382
1382
return self [ start..< endIndex]
1383
1383
}
1384
1384
@@ -1677,9 +1677,9 @@ extension Collection where SubSequence == Self {
1677
1677
public mutating func removeFirst( _ n: Int ) {
1678
1678
if n == 0 { return }
1679
1679
_precondition ( n >= 0 , " Number of elements to remove should be non-negative " )
1680
- _precondition ( count >= numericCast ( n ) ,
1680
+ _precondition ( count >= n ,
1681
1681
" Can't remove more items from a collection than it contains " )
1682
- self = self [ index ( startIndex, offsetBy: numericCast ( n ) ) ..< endIndex]
1682
+ self = self [ index ( startIndex, offsetBy: n ) ..< endIndex]
1683
1683
}
1684
1684
}
1685
1685
0 commit comments