Remove extraneous get { from a bunch of read-only accessors.

This commit is contained in:
Brent Simmons
2018-02-14 13:14:25 -08:00
parent 192439abe7
commit 2f21dbf6be
44 changed files with 216 additions and 353 deletions

View File

@@ -14,9 +14,7 @@ public final class DownloadObject: Hashable {
public var data = Data()
public var hashValue: Int {
get {
return url.hashValue
}
return url.hashValue
}
public init(url: URL) {

View File

@@ -35,22 +35,18 @@ public final class DownloadProgress {
}
public var numberCompleted: Int {
get {
var n = numberOfTasks - numberRemaining
if n < 0 {
n = 0
}
if n > numberOfTasks {
n = numberOfTasks
}
return n
var n = numberOfTasks - numberRemaining
if n < 0 {
n = 0
}
if n > numberOfTasks {
n = numberOfTasks
}
return n
}
public var isComplete: Bool {
get {
return numberRemaining < 1
}
return numberRemaining < 1
}
public init(numberOfTasks: Int) {

View File

@@ -294,9 +294,7 @@ private final class DownloadInfo {
var canceled = false
var statusCode: Int {
get {
return urlResponse?.forcedStatusCode ?? 0
}
return urlResponse?.forcedStatusCode ?? 0
}
init(_ representedObject: AnyObject, urlRequest: URLRequest) {

View File

@@ -12,18 +12,16 @@ public struct HTTPConditionalGetInfo {
public let lastModified: String?
public let etag: String?
public var dictionary: [String: String] {
get {
var d = [String: String]()
if let lastModified = lastModified {
d[HTTPResponseHeader.lastModified] = lastModified
}
if let etag = etag {
d[HTTPResponseHeader.etag] = etag
}
return d
var d = [String: String]()
if let lastModified = lastModified {
d[HTTPResponseHeader.lastModified] = lastModified
}
if let etag = etag {
d[HTTPResponseHeader.etag] = etag
}
return d
}
public init?(lastModified: String?, etag: String?) {

View File

@@ -9,23 +9,19 @@
import Foundation
public extension URLResponse {
public var statusIsOK: Bool {
get {
return forcedStatusCode >= 200 && forcedStatusCode <= 299
}
return forcedStatusCode >= 200 && forcedStatusCode <= 299
}
public var forcedStatusCode: Int {
get {
// Return actual statusCode or -1 if there isnt one.
if let response = self as? HTTPURLResponse {
return response.statusCode
}
return 0
// Return actual statusCode or -1 if there isnt one.
if let response = self as? HTTPURLResponse {
return response.statusCode
}
return 0
}
}