Skip to content

Commit 3995b2c

Browse files
authored
Merge pull request #1728 from benasher44/patch-1
2 parents e5cda91 + 2203872 commit 3995b2c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Foundation/UUID.swift

Lines changed: 4 additions & 7 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) { valPtr in
65+
return withUnsafePointer(to: uuid) { valPtr in
6766
valPtr.withMemoryRebound(to: UInt8.self, capacity: MemoryLayout<uuid_t>.size) { val in
6867
withUnsafeMutablePointer(to: &bytes) { strPtr in
6968
strPtr.withMemoryRebound(to: CChar.self, capacity: MemoryLayout<uuid_string_t>.size) { str in
@@ -76,10 +75,9 @@ 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: MemoryLayout<uuid_t>.size) {
82-
return Int(bitPattern: CFHashBytes($0, CFIndex(MemoryLayout<uuid_t>.size)))
80+
return Int(bitPattern: CFHashBytes(UnsafeMutablePointer(mutating: $0), CFIndex(MemoryLayout<uuid_t>.size)))
8381
}
8482
}
8583
}
@@ -95,8 +93,7 @@ public struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConv
9593
// MARK: - Bridging Support
9694

9795
fileprivate var reference: NSUUID {
98-
var bytes = uuid
99-
return withUnsafePointer(to: &bytes) {
96+
return withUnsafePointer(to: uuid) {
10097
$0.withMemoryRebound(to: UInt8.self, capacity: MemoryLayout<uuid_t>.size) {
10198
return NSUUID(uuidBytes: $0)
10299
}

0 commit comments

Comments
 (0)