From 8cd49082ec72a9e9acaa5c33f49ef866c189cde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 9 Feb 2019 09:56:12 +0100 Subject: [PATCH] SE-0205 withUnsafePointer(to:_:) and withUnsafeBytes(of:_:) for immutable values --- GRDB/Core/DatabaseFunction.swift | 4 ++-- GRDB/Core/Support/Foundation/UUID.swift | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/GRDB/Core/DatabaseFunction.swift b/GRDB/Core/DatabaseFunction.swift index 3cb7323ed..b22e6a08e 100644 --- a/GRDB/Core/DatabaseFunction.swift +++ b/GRDB/Core/DatabaseFunction.swift @@ -275,8 +275,8 @@ public final class DatabaseFunction: Hashable { // retain and store in SQLite's buffer let aggregateContextU = Unmanaged.passRetained(aggregateContext) - var aggregateContextP = aggregateContextU.toOpaque() - withUnsafeBytes(of: &aggregateContextP) { + let aggregateContextP = aggregateContextU.toOpaque() + withUnsafeBytes(of: aggregateContextP) { aggregateContextBufferP.copyMemory(from: $0) } return aggregateContextU diff --git a/GRDB/Core/Support/Foundation/UUID.swift b/GRDB/Core/Support/Foundation/UUID.swift index b3f03fb05..a2b241631 100644 --- a/GRDB/Core/Support/Foundation/UUID.swift +++ b/GRDB/Core/Support/Foundation/UUID.swift @@ -45,8 +45,7 @@ extension NSUUID: DatabaseValueConvertible { /// UUID adopts DatabaseValueConvertible extension UUID: DatabaseValueConvertible { public var databaseValue: DatabaseValue { - var uuid_t = uuid - return withUnsafeBytes(of: &uuid_t) { + return withUnsafeBytes(of: uuid) { Data(bytes: $0.baseAddress!, count: $0.count).databaseValue } }