Skip to content

Commit d79d52c

Browse files
committed
Simplify sync
#640
1 parent dc1b643 commit d79d52c

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

Sources/SQLite/Core/Connection.swift

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -626,29 +626,12 @@ public final class Connection {
626626

627627
// MARK: - Error Handling
628628

629-
func sync<T>(_ block: @escaping () throws -> T) rethrows -> T {
630-
var success: T?
631-
var failure: Error?
632-
633-
let box: () -> Void = {
634-
do {
635-
success = try block()
636-
} catch {
637-
failure = error
638-
}
639-
}
640-
629+
func sync<T>(_ block: () throws -> T) rethrows -> T {
641630
if DispatchQueue.getSpecific(key: Connection.queueKey) == queueContext {
642-
box()
631+
return try block()
643632
} else {
644-
queue.sync(execute: box) // FIXME: rdar://problem/21389236
645-
}
646-
647-
if let failure = failure {
648-
try { () -> Void in throw failure }()
633+
return try queue.sync(execute: block)
649634
}
650-
651-
return success!
652635
}
653636

654637
@discardableResult func check(_ resultCode: Int32, statement: Statement? = nil) throws -> Int32 {

0 commit comments

Comments
 (0)