mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Assume NSUUID.fromDatabaseValue no longer needs special care in Release configuration, since we target Xcode 10+ now
This commit is contained in:
1 parent
22edb91796
commit
0fe7db2694
1 file changed
+9
-14
@@ -19,20 +19,15 @@ extension NSUUID: DatabaseValueConvertible {
|
||||
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
|
||||
switch dbValue.storage {
|
||||
case .blob(let data) where data.count == 16:
|
||||
// TODO: Simplify now that Xcode 10+ is required.
|
||||
// The code below works in debug configuration, but crashes in
|
||||
// release configuration (Xcode 9.4.1)
|
||||
|
||||
// return data.withUnsafeBytes {
|
||||
// self.init(uuidBytes: $0)
|
||||
// }
|
||||
|
||||
// Workaround (involves a useless copy)
|
||||
let buffer = UnsafeMutableBufferPointer<UInt8>.allocate(capacity: 16)
|
||||
_ = data.copyBytes(to: buffer)
|
||||
let uuid = self.init(uuidBytes: UnsafePointer(buffer.baseAddress!))
|
||||
buffer.deallocate()
|
||||
return uuid
|
||||
#if swift(>=5.0)
|
||||
return data.withUnsafeBytes {
|
||||
self.init(uuidBytes: $0.bindMemory(to: UInt8.self).baseAddress)
|
||||
}
|
||||
#else
|
||||
return data.withUnsafeBytes {
|
||||
self.init(uuidBytes: $0)
|
||||
}
|
||||
#endif
|
||||
case .string(let string):
|
||||
return self.init(uuidString: string)
|
||||
default:
|
||||
|
||||
Reference in new issue
Block a user