Skip to content

Gets rid of for-loop deprecation compiler warnings in stdlib/private #653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,8 @@ public func runAllTests() {
} else {
var runTestsInProcess: Bool = false
var filter: String? = nil
for var i = 0; i < Process.arguments.count; {
var i = 0
while i < Process.arguments.count {
let arg = Process.arguments[i]
if arg == "--stdlib-unittest-in-process" {
runTestsInProcess = true
Expand Down
6 changes: 3 additions & 3 deletions stdlib/private/SwiftPrivate/ShardedAtomicCounter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public struct _stdlib_ShardedAtomicCounter {
let hardwareConcurrency = _stdlib_getHardwareConcurrency()
let count = max(8, hardwareConcurrency * hardwareConcurrency)
let shards = UnsafeMutablePointer<Int>.alloc(count)
for var i = 0; i != count; i++ {
for i in 0..<count {
(shards + i).initialize(0)
}
self._shardsPtr = shards
Expand All @@ -57,7 +57,7 @@ public struct _stdlib_ShardedAtomicCounter {
var result = 0
let shards = self._shardsPtr
let count = self._shardsCount
for var i = 0; i != count; i++ {
for i in 0..<count {
result += _swift_stdlib_atomicLoadInt(object: shards + i)
}
return result
Expand All @@ -72,7 +72,7 @@ public struct _stdlib_ShardedAtomicCounter {

public mutating func randomInt() -> Int {
var result = 0
for var i = 0; i != Int._sizeInBits; ++i {
for _ in 0..<Int._sizeInBits {
result = (result << 1) | (_state & 1)
_state = (_state >> 1) ^ (-(_state & 1) & Int(bitPattern: 0xD0000001))
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/private/SwiftPrivate/SwiftPrivate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public func scan<

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