Skip to content

Commit 92beea2

Browse files
authored
Merge pull request #1463 from aschwaighofer/fix_withoutActuallyEscaping_usage
NSDictionary, NSIndexSet: Fix withoutAcutallyEscaping usage
2 parents 4b7978a + 1b6a9d2 commit 92beea2

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

Foundation/NSDictionary.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ open class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
483483
let lock = NSLock()
484484

485485
getObjects(&objects, andKeys: &keys, count: count)
486-
let iteration: (Int) -> Void = withoutActuallyEscaping(block) { (closure: @escaping (Any, Any, UnsafeMutablePointer<ObjCBool>) -> Void) -> (Int) -> Void in
487-
return { (idx) in
486+
withoutActuallyEscaping(block) { (closure: @escaping (Any, Any, UnsafeMutablePointer<ObjCBool>) -> Void) -> () in
487+
let iteration: (Int) -> Void = { (idx) in
488488
lock.lock()
489489
var stop = sharedStop
490490
lock.unlock()
@@ -499,13 +499,13 @@ open class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
499499
return
500500
}
501501
}
502-
}
503-
504-
if opts.contains(.concurrent) {
505-
DispatchQueue.concurrentPerform(iterations: count, execute: iteration)
506-
} else {
507-
for idx in 0..<count {
508-
iteration(idx)
502+
503+
if opts.contains(.concurrent) {
504+
DispatchQueue.concurrentPerform(iterations: count, execute: iteration)
505+
} else {
506+
for idx in 0..<count {
507+
iteration(idx)
508+
}
509509
}
510510
}
511511
}

Foundation/NSIndexSet.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ open class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
389389
let lock = NSLock()
390390
let ranges = _ranges[startRangeIndex...endRangeIndex]
391391
let rangeSequence = (reverse ? AnyCollection(ranges.reversed()) : AnyCollection(ranges))
392-
let iteration = withoutActuallyEscaping(block) { (closure: @escaping (P, UnsafeMutablePointer<ObjCBool>) -> R) -> (Int) -> Void in
393-
return { (rangeIdx) in
392+
withoutActuallyEscaping(block) { (closure: @escaping (P, UnsafeMutablePointer<ObjCBool>) -> R) -> () in
393+
let iteration : (Int) -> Void = { (rangeIdx) in
394394
lock.lock()
395395
var stop = ObjCBool(sharedStop)
396396
lock.unlock()
@@ -431,13 +431,12 @@ open class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
431431
}
432432
}
433433
}
434-
}
435-
436-
if opts.contains(.concurrent) {
437-
DispatchQueue.concurrentPerform(iterations: Int(rangeSequence.count), execute: iteration)
438-
} else {
439-
for idx in 0..<Int(rangeSequence.count) {
440-
iteration(idx)
434+
if opts.contains(.concurrent) {
435+
DispatchQueue.concurrentPerform(iterations: Int(rangeSequence.count), execute: iteration)
436+
} else {
437+
for idx in 0..<Int(rangeSequence.count) {
438+
iteration(idx)
439+
}
441440
}
442441
}
443442

0 commit comments

Comments
 (0)