Use optional binding instead of comparing to nil and force-unwrapping

This commit is contained in:
Matt Rubin 2016-12-17 01:33:36 -05:00
parent 6244bdfdc6
commit 160428039e

View File

@ -15,8 +15,8 @@ public typealias CheckoutProgressBlock = (String?, Int, Int) -> Void
/// Helper function used as the libgit2 progress callback in git_checkout_options.
/// This is a function with a type signature of git_checkout_progress_cb.
private func checkoutProgressCallback(path: UnsafePointer<Int8>?, completed_steps: Int, total_steps: Int, payload: UnsafeMutableRawPointer?) -> Void {
if (payload != nil) {
let buffer = payload!.assumingMemoryBound(to: CheckoutProgressBlock.self)
if let payload = payload {
let buffer = payload.assumingMemoryBound(to: CheckoutProgressBlock.self)
let block: CheckoutProgressBlock
if completed_steps < total_steps {
block = buffer.pointee