Skip to content

Commit 4163848

Browse files
authored
Update UUID to take advantage of SE-0205
This updates UUID to use withUnsafePointer for lets
1 parent 5d4f3c8 commit 4163848

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Darwin/Foundation-swiftoverlay/UUID.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConv
6262
/// Returns a string created from the UUID, such as "E621E1F8-C36C-495A-93FC-0C247A3E6E5F"
6363
public var uuidString: String {
6464
var bytes: uuid_string_t = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
65-
var localValue = uuid
66-
return withUnsafeMutablePointer(to: &localValue) {
65+
return withUnsafePointer(to: uuid) {
6766
$0.withMemoryRebound(to: UInt8.self, capacity: 16) { val in
6867
withUnsafeMutablePointer(to: &bytes) {
6968
$0.withMemoryRebound(to: Int8.self, capacity: 37) { str in
@@ -76,8 +75,7 @@ public struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConv
7675
}
7776

7877
public var hashValue: Int {
79-
var localValue = uuid
80-
return withUnsafeMutablePointer(to: &localValue) {
78+
return withUnsafePointer(to: uuid) {
8179
$0.withMemoryRebound(to: UInt8.self, capacity: 16) {
8280
return Int(bitPattern: CFHashBytes($0, CFIndex(MemoryLayout<uuid_t>.size)))
8381
}

0 commit comments

Comments
 (0)