Skip to content

Commit 03543f6

Browse files
xwuparkera
authored andcommitted
[SE-0127] Remove calls to withUnsafe[Mutable]Pointers (#473)
1 parent dd9e438 commit 03543f6

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

Foundation/NSCalendar.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,10 @@ public class Calendar: NSObject, NSCopying, NSSecureCoding {
394394
public func range(of unit: Unit, forDate date: Date) -> DateInterval? {
395395
var start: CFAbsoluteTime = 0.0
396396
var ti: CFTimeInterval = 0.0
397-
let res: Bool = withUnsafeMutablePointers(&start, &ti) { startp, tip in
398-
return CFCalendarGetTimeRangeOfUnit(_cfObject, unit._cfValue, date.timeIntervalSinceReferenceDate, startp, tip)
397+
let res: Bool = withUnsafeMutablePointer(&start) { startp in
398+
withUnsafeMutablePointer(&ti) { tip in
399+
return CFCalendarGetTimeRangeOfUnit(_cfObject, unit._cfValue, date.timeIntervalSinceReferenceDate, startp, tip)
400+
}
399401
}
400402

401403
if res {

Foundation/NSPropertyList.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ public class PropertyListSerialization : NSObject {
7070
public class func propertyList(from data: Data, options opt: ReadOptions = [], format: UnsafeMutablePointer<PropertyListFormat>?) throws -> Any {
7171
var fmt = kCFPropertyListBinaryFormat_v1_0
7272
var error: Unmanaged<CFError>? = nil
73-
let decoded = withUnsafeMutablePointers(&fmt, &error) { (outFmt: UnsafeMutablePointer<CFPropertyListFormat>, outErr: UnsafeMutablePointer<Unmanaged<CFError>?>) -> NSObject? in
74-
return unsafeBitCast(CFPropertyListCreateWithData(kCFAllocatorSystemDefault, data._cfObject, CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr), to: NSObject.self)
73+
let decoded = withUnsafeMutablePointer(&fmt) { (outFmt: UnsafeMutablePointer<CFPropertyListFormat>) -> NSObject? in
74+
withUnsafeMutablePointer(&error) { (outErr: UnsafeMutablePointer<Unmanaged<CFError>?>) -> NSObject? in
75+
return unsafeBitCast(CFPropertyListCreateWithData(kCFAllocatorSystemDefault, data._cfObject, CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr), to: NSObject.self)
76+
}
7577
}
7678
#if os(OSX) || os(iOS)
7779
format?.pointee = PropertyListFormat(rawValue: UInt(fmt.rawValue))!

Foundation/NSThread.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ public class Thread: NSObject {
170170
public var stackSize: Int {
171171
get {
172172
var size: Int = 0
173-
return withUnsafeMutablePointers(&_attr, &size) { attr, sz in
174-
pthread_attr_getstacksize(attr, sz)
175-
return sz.pointee
173+
return withUnsafeMutablePointer(&_attr) { attr in
174+
withUnsafeMutablePointer(&size) { sz in
175+
pthread_attr_getstacksize(attr, sz)
176+
return sz.pointee
177+
}
176178
}
177179
}
178180
set {

0 commit comments

Comments
 (0)