Skip to content

Commit ec47dd3

Browse files
committed
Change Blob internal value from NSData to [UInt8]
1 parent 03b27f9 commit ec47dd3

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

SQLite/Value.swift

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
// THE SOFTWARE.
2323
//
2424

25-
import Foundation
26-
2725
/// Binding is a protocol that SQLite.swift uses internally to directly map
2826
/// SQLite types to Swift types.
2927
///
@@ -47,30 +45,37 @@ public protocol Value {
4745

4846
}
4947

50-
public struct Blob {
51-
52-
private let data: NSData
48+
public struct Blob: Equatable {
5349

54-
public var bytes: UnsafePointer<Void> {
55-
return data.bytes
50+
public let data: [UInt8]
51+
52+
public init(data: [UInt8]) {
53+
self.data = data
5654
}
57-
58-
public var length: Int {
59-
return data.length
60-
}
61-
55+
6256
public init(bytes: UnsafePointer<Void>, length: Int) {
63-
data = NSData(bytes: bytes, length: length)
57+
self.data = [UInt8](UnsafeBufferPointer<UInt8>(
58+
start: UnsafePointer<UInt8>(bytes),
59+
count: length
60+
))
6461
}
6562

6663
}
6764

68-
extension Blob: Equatable {}
69-
7065
public func ==(lhs: Blob, rhs: Blob) -> Bool {
7166
return lhs.data == rhs.data
7267
}
7368

69+
extension Blob {
70+
public var bytes: UnsafePointer<Void> {
71+
return UnsafePointer<Void>(data)
72+
}
73+
74+
public var length: Int {
75+
return data.count
76+
}
77+
}
78+
7479
extension Blob: Binding, Value {
7580

7681
public static var declaredDatatype = "BLOB"

0 commit comments

Comments
 (0)