Skip to content

Commit 1dae128

Browse files
committed
Gets rid of for-loop deprecation compiler warnings in stdlib/private
1 parent faba6e5 commit 1dae128

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,8 @@ public func runAllTests() {
782782
} else {
783783
var runTestsInProcess: Bool = false
784784
var filter: String? = nil
785-
for var i = 0; i < Process.arguments.count; {
785+
var i = 0
786+
while i < Process.arguments.count {
786787
let arg = Process.arguments[i]
787788
if arg == "--stdlib-unittest-in-process" {
788789
runTestsInProcess = true

stdlib/private/SwiftPrivate/ShardedAtomicCounter.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public struct _stdlib_ShardedAtomicCounter {
3434
let hardwareConcurrency = _stdlib_getHardwareConcurrency()
3535
let count = max(8, hardwareConcurrency * hardwareConcurrency)
3636
let shards = UnsafeMutablePointer<Int>.alloc(count)
37-
for var i = 0; i != count; i++ {
37+
for i in 0..<count {
3838
(shards + i).initialize(0)
3939
}
4040
self._shardsPtr = shards
@@ -57,7 +57,7 @@ public struct _stdlib_ShardedAtomicCounter {
5757
var result = 0
5858
let shards = self._shardsPtr
5959
let count = self._shardsCount
60-
for var i = 0; i != count; i++ {
60+
for i in 0..<count {
6161
result += _swift_stdlib_atomicLoadInt(object: shards + i)
6262
}
6363
return result
@@ -72,7 +72,7 @@ public struct _stdlib_ShardedAtomicCounter {
7272

7373
public mutating func randomInt() -> Int {
7474
var result = 0
75-
for var i = 0; i != Int._sizeInBits; ++i {
75+
for _ in 0..<Int._sizeInBits {
7676
result = (result << 1) | (_state & 1)
7777
_state = (_state >> 1) ^ (-(_state & 1) & Int(bitPattern: 0xD0000001))
7878
}

stdlib/private/SwiftPrivate/SwiftPrivate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public func scan<
4343

4444
public func randomShuffle<T>(a: [T]) -> [T] {
4545
var result = a
46-
for var i = a.count - 1; i != 0; --i {
46+
for i in (1..<a.count).reverse() {
4747
// FIXME: 32 bits are not enough in general case!
4848
let j = Int(rand32(exclusiveUpperBound: UInt32(i + 1)))
4949
if i != j {

0 commit comments

Comments
 (0)