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

@ -17,9 +17,7 @@ final class DeleteFromSidebarCommand: UndoableCommand {
let undoManager: UndoManager let undoManager: UndoManager
let undoActionName: String let undoActionName: String
var redoActionName: String { var redoActionName: String {
get { return undoActionName
return undoActionName
}
} }
private let itemSpecifiers: [SidebarItemSpecifier] private let itemSpecifiers: [SidebarItemSpecifier]
@ -94,15 +92,13 @@ private struct SidebarItemSpecifier {
private let path: ContainerPath private let path: ContainerPath
private var container: Container? { private var container: Container? {
get { if let parentFolder = parentFolder {
if let parentFolder = parentFolder { return parentFolder
return parentFolder
}
if let account = account {
return account
}
return nil
} }
if let account = account {
return account
}
return nil
} }
init?(node: Node) { init?(node: Node) {

View File

@ -42,26 +42,18 @@ private func accountAndArticlesDictionary(_ articles: Set<Article>) -> [String:
extension Article { extension Article {
var feed: Feed? { var feed: Feed? {
get { return account?.existingFeed(with: feedID)
return account?.existingFeed(with: feedID)
}
} }
var preferredLink: String? { var preferredLink: String? {
get { return url ?? externalURL
return url ?? externalURL
}
} }
var body: String? { var body: String? {
get { return contentHTML ?? contentText ?? summary
return contentHTML ?? contentText ?? summary
}
} }
var logicalDatePublished: Date { var logicalDatePublished: Date {
get { return datePublished ?? dateModified ?? status.dateArrived
return datePublished ?? dateModified ?? status.dateArrived
}
} }
} }

View File

@ -31,9 +31,7 @@ final class FeedListFeed: Hashable, DisplayNameProvider {
} }
var nameForDisplay: String { // DisplayNameProvider var nameForDisplay: String { // DisplayNameProvider
get { return name
return name
}
} }
init(name: String, url: String, homePageURL: String) { init(name: String, url: String, homePageURL: String) {

View File

@ -17,9 +17,7 @@ final class FeedListFolder: Hashable, DisplayNameProvider {
let hashValue: Int let hashValue: Int
var nameForDisplay: String { // DisplayNameProvider var nameForDisplay: String { // DisplayNameProvider
get { return name
return name
}
} }
init(name: String, feeds: Set<FeedListFeed>) { init(name: String, feeds: Set<FeedListFeed>) {

View File

@ -33,9 +33,7 @@ final class InspectorWindowController: NSWindowController {
} }
var isOpen: Bool { var isOpen: Bool {
get { return isWindowLoaded && window!.isVisible
return isWindowLoaded && window!.isVisible
}
} }
private var inspectors: [InspectorViewController]! private var inspectors: [InspectorViewController]!

View File

@ -126,12 +126,10 @@ class AddFeedController: AddFeedWindowControllerDelegate, FeedFinderDelegate {
private extension AddFeedController { private extension AddFeedController {
var urlStringFromPasteboard: String? { var urlStringFromPasteboard: String? {
get { if let urlString = NSPasteboard.rs_urlString(from: NSPasteboard.general) {
if let urlString = NSPasteboard.rs_urlString(from: NSPasteboard.general) { return urlString.rs_normalizedURL()
return urlString.rs_normalizedURL()
}
return nil
} }
return nil
} }
struct AccountAndFolderSpecifier { struct AccountAndFolderSpecifier {

View File

@ -33,14 +33,12 @@ class AddFeedWindowController : NSWindowController {
fileprivate var folderTreeController: TreeController! fileprivate var folderTreeController: TreeController!
private var userEnteredTitle: String? { private var userEnteredTitle: String? {
get { var s = nameTextField.stringValue
var s = nameTextField.stringValue s = s.rs_stringWithCollapsedWhitespace()
s = s.rs_stringWithCollapsedWhitespace() if s.isEmpty {
if s.isEmpty { return nil
return nil
}
return s
} }
return s
} }
var hostWindow: NSWindow! var hostWindow: NSWindow!

View File

@ -13,8 +13,6 @@ class MainWindowSplitView: NSSplitView {
private let splitViewDividerColor = NSColor(calibratedWhite: 0.65, alpha: 1.0) private let splitViewDividerColor = NSColor(calibratedWhite: 0.65, alpha: 1.0)
override var dividerColor: NSColor { override var dividerColor: NSColor {
get { return splitViewDividerColor
return splitViewDividerColor
}
} }
} }

View File

@ -75,9 +75,7 @@ class SidebarCell : NSTableCellView {
} }
override var isFlipped: Bool { override var isFlipped: Bool {
get { return true
return true
}
} }
private func commonInit() { private func commonInit() {

View File

@ -25,9 +25,7 @@ final class SidebarStatusBarView: NSView {
} }
override var isFlipped: Bool { override var isFlipped: Bool {
get { return true
return true
}
} }
override func awakeFromNib() { override func awakeFromNib() {

View File

@ -27,34 +27,28 @@ class UnreadCountView : NSView {
} }
} }
var unreadCountString: String { var unreadCountString: String {
get { return unreadCount < 1 ? "" : "\(unreadCount)"
return unreadCount < 1 ? "" : "\(unreadCount)"
}
} }
private var intrinsicContentSizeIsValid = false private var intrinsicContentSizeIsValid = false
private var _intrinsicContentSize = NSZeroSize private var _intrinsicContentSize = NSZeroSize
override var intrinsicContentSize: NSSize { override var intrinsicContentSize: NSSize {
get { if !intrinsicContentSizeIsValid {
if !intrinsicContentSizeIsValid { var size = NSZeroSize
var size = NSZeroSize if unreadCount > 0 {
if unreadCount > 0 { size = textSize()
size = textSize() size.width += (padding.left + padding.right)
size.width += (padding.left + padding.right) size.height += (padding.top + padding.bottom)
size.height += (padding.top + padding.bottom)
}
_intrinsicContentSize = size
intrinsicContentSizeIsValid = true
} }
return _intrinsicContentSize _intrinsicContentSize = size
intrinsicContentSizeIsValid = true
} }
return _intrinsicContentSize
} }
override var isFlipped: Bool { override var isFlipped: Bool {
get { return true
return true
}
} }
override func invalidateIntrinsicContentSize() { override func invalidateIntrinsicContentSize() {

View File

@ -23,14 +23,12 @@ class TimelineTableRowView : NSTableRowView {
// } // }
private var cellView: TimelineTableCellView? { private var cellView: TimelineTableCellView? {
get { for oneSubview in subviews {
for oneSubview in subviews { if let foundView = oneSubview as? TimelineTableCellView {
if let foundView = oneSubview as? TimelineTableCellView { return foundView
return foundView
}
} }
return nil
} }
return nil
} }
override var isEmphasized: Bool { override var isEmphasized: Bool {
@ -50,10 +48,7 @@ class TimelineTableRowView : NSTableRowView {
} }
var gridRect: NSRect { var gridRect: NSRect {
get { return NSMakeRect(0.0, NSMaxY(bounds) - 1.0, NSWidth(bounds), 1)
// return NSMakeRect(floor(cellAppearance.boxLeftMargin), NSMaxY(bounds) - 1.0, NSWidth(bounds), 1)
return NSMakeRect(0.0, NSMaxY(bounds) - 1.0, NSWidth(bounds), 1)
}
} }
override func drawSeparator(in dirtyRect: NSRect) { override func drawSeparator(in dirtyRect: NSRect) {

View File

@ -18,15 +18,11 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
@IBOutlet var contextualMenuDelegate: TimelineContextualMenuDelegate? @IBOutlet var contextualMenuDelegate: TimelineContextualMenuDelegate?
var selectedArticles: [Article] { var selectedArticles: [Article] {
get { return Array(articles.articlesForIndexes(tableView.selectedRowIndexes))
return Array(articles.articlesForIndexes(tableView.selectedRowIndexes))
}
} }
var hasAtLeastOneSelectedArticle: Bool { var hasAtLeastOneSelectedArticle: Bool {
get { return tableView.selectedRow != -1
return tableView.selectedRow != -1
}
} }
var articles = ArticleArray() { var articles = ArticleArray() {
@ -105,9 +101,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
} }
private var oneSelectedArticle: Article? { private var oneSelectedArticle: Article? {
get { return selectedArticles.count == 1 ? selectedArticles.first : nil
return selectedArticles.count == 1 ? selectedArticles.first : nil
}
} }
override func viewDidLoad() { override func viewDidLoad() {

View File

@ -96,9 +96,7 @@ class PreferencesWindowController : NSWindowController, NSToolbarDelegate {
private extension PreferencesWindowController { private extension PreferencesWindowController {
var currentView: NSView? { var currentView: NSView? {
get { return window?.contentView?.subviews.first
return window?.contentView?.subviews.first
}
} }
func toolbarItemSpec(for identifier: String) -> PreferencesToolbarItemSpec? { func toolbarItemSpec(for identifier: String) -> PreferencesToolbarItemSpec? {

View File

@ -22,8 +22,6 @@ private var smartFeedIcon: NSImage = {
extension PseudoFeed { extension PseudoFeed {
var smallIcon: NSImage? { var smallIcon: NSImage? {
get { return smartFeedIcon
return smartFeedIcon
}
} }
} }

View File

@ -19,9 +19,7 @@ protocol SmartFeedDelegate: DisplayNameProvider, ArticleFetcher {
final class SmartFeed: PseudoFeed { final class SmartFeed: PseudoFeed {
var nameForDisplay: String { var nameForDisplay: String {
get { return delegate.nameForDisplay
return delegate.nameForDisplay
}
} }
var unreadCount = 0 { var unreadCount = 0 {

View File

@ -102,15 +102,11 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
} }
var refreshProgress: DownloadProgress { var refreshProgress: DownloadProgress {
get { return delegate.refreshProgress
return delegate.refreshProgress
}
} }
var supportsSubFolders: Bool { var supportsSubFolders: Bool {
get { return delegate.supportsSubFolders
return delegate.supportsSubFolders
}
} }
init?(dataFolder: String, settingsFile: String, type: AccountType, accountID: String) { init?(dataFolder: String, settingsFile: String, type: AccountType, accountID: String) {

View File

@ -31,33 +31,25 @@ public final class AccountManager: UnreadCountProvider {
} }
public var accounts: [Account] { public var accounts: [Account] {
get { return Array(accountsDictionary.values)
return Array(accountsDictionary.values)
}
} }
public var sortedAccounts: [Account] { public var sortedAccounts: [Account] {
get { return accountsSortedByName()
return accountsSortedByName()
}
} }
public var refreshInProgress: Bool { public var refreshInProgress: Bool {
get { for account in accounts {
for account in accounts { if account.refreshInProgress {
if account.refreshInProgress { return true
return true
}
} }
return false
} }
return false
} }
public var combinedRefreshProgress: CombinedRefreshProgress { public var combinedRefreshProgress: CombinedRefreshProgress {
get { let downloadProgressArray = accounts.map { $0.refreshProgress }
let downloadProgressArray = accounts.map { $0.refreshProgress } return CombinedRefreshProgress(downloadProgressArray: downloadProgressArray)
return CombinedRefreshProgress(downloadProgressArray: downloadProgressArray)
}
} }
public init() { public init() {

View File

@ -18,9 +18,7 @@ public extension Notification.Name {
public extension Feed { public extension Feed {
public var account: Account? { public var account: Account? {
get { return AccountManager.shared.existingAccount(with: accountID)
return AccountManager.shared.existingAccount(with: accountID)
}
} }
public func takeSettings(from parsedFeed: ParsedFeed) { public func takeSettings(from parsedFeed: ParsedFeed) {
@ -59,15 +57,11 @@ public extension Feed {
public extension Article { public extension Article {
public var account: Account? { public var account: Account? {
get { return AccountManager.shared.existingAccount(with: accountID)
return AccountManager.shared.existingAccount(with: accountID)
}
} }
public var feed: Feed? { public var feed: Feed? {
get { return account?.existingFeed(with: feedID)
return account?.existingFeed(with: feedID)
}
} }
} }

View File

@ -14,9 +14,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
let supportsSubFolders = false let supportsSubFolders = false
var refreshProgress: DownloadProgress { var refreshProgress: DownloadProgress {
get { return DownloadProgress(numberOfTasks: 0) // TODO
return DownloadProgress(numberOfTasks: 0) // TODO
}
} }
func refreshAll(for: Account) { func refreshAll(for: Account) {

View File

@ -29,10 +29,7 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
// MARK: - DisplayNameProvider // MARK: - DisplayNameProvider
public var nameForDisplay: String { public var nameForDisplay: String {
get { return name ?? Folder.untitledName
return name ?? Folder.untitledName
}
} }
// MARK: - UnreadCountProvider // MARK: - UnreadCountProvider
@ -84,38 +81,36 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
} }
var dictionary: [String: Any] { var dictionary: [String: Any] {
get {
var d = [String: Any]()
guard let account = account else {
return d
}
if let name = name {
d[Key.name] = name
}
if unreadCount > 0 {
d[Key.unreadCount] = unreadCount
}
let childObjects = children.compactMap { (child) -> [String: Any]? in
if let feed = child as? Feed {
return feed.dictionary
}
if let folder = child as? Folder, account.supportsSubFolders {
return folder.dictionary
}
assertionFailure("Expected a feed or a folder.");
return nil
}
if !childObjects.isEmpty {
d[Key.children] = childObjects
}
var d = [String: Any]()
guard let account = account else {
return d return d
} }
if let name = name {
d[Key.name] = name
}
if unreadCount > 0 {
d[Key.unreadCount] = unreadCount
}
let childObjects = children.compactMap { (child) -> [String: Any]? in
if let feed = child as? Feed {
return feed.dictionary
}
if let folder = child as? Folder, account.supportsSubFolders {
return folder.dictionary
}
assertionFailure("Expected a feed or a folder.");
return nil
}
if !childObjects.isEmpty {
d[Key.children] = childObjects
}
return d
} }
// MARK: Feeds // MARK: Feeds

View File

@ -15,9 +15,7 @@ final class LocalAccountDelegate: AccountDelegate {
private let refresher = LocalAccountRefresher() private let refresher = LocalAccountRefresher()
var refreshProgress: DownloadProgress { var refreshProgress: DownloadProgress {
get { return refresher.progress
return refresher.progress
}
} }
func refreshAll(for account: Account) { func refreshAll(for account: Account) {

View File

@ -19,9 +19,7 @@ final class LocalAccountRefresher {
}() }()
var progress: DownloadProgress { var progress: DownloadProgress {
get { return downloadSession.progress
return downloadSession.progress
}
} }
public func refreshFeeds(_ feeds: Set<Feed>) { public func refreshFeeds(_ feeds: Set<Feed>) {

View File

@ -34,15 +34,13 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
// MARK: - DisplayNameProvider // MARK: - DisplayNameProvider
public var nameForDisplay: String { public var nameForDisplay: String {
get { if let s = editedName, !s.isEmpty {
if let s = editedName, !s.isEmpty { return s
return s
}
if let s = name, !s.isEmpty {
return s
}
return NSLocalizedString("Untitled", comment: "Feed name")
} }
if let s = name, !s.isEmpty {
return s
}
return NSLocalizedString("Untitled", comment: "Feed name")
} }
// MARK: - UnreadCountProvider // MARK: - UnreadCountProvider
@ -115,46 +113,44 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
} }
public var dictionary: [String: Any] { public var dictionary: [String: Any] {
get { var d = [String: Any]()
var d = [String: Any]()
d[Key.url] = url d[Key.url] = url
// feedID is not repeated when its the same as url // feedID is not repeated when its the same as url
if (feedID != url) { if (feedID != url) {
d[Key.feedID] = feedID d[Key.feedID] = feedID
}
if let homePageURL = homePageURL {
d[Key.homePageURL] = homePageURL
}
if let iconURL = iconURL {
d[Key.iconURL] = iconURL
}
if let faviconURL = faviconURL {
d[Key.faviconURL] = faviconURL
}
if let name = name {
d[Key.name] = name
}
if let editedName = editedName {
d[Key.editedName] = editedName
}
if let authorsArray = authors?.diskArray() {
d[Key.authors] = authorsArray
}
if let contentHash = contentHash {
d[Key.contentHash] = contentHash
}
if unreadCount > 0 {
d[Key.unreadCount] = unreadCount
}
if let conditionalGetInfo = conditionalGetInfo {
d[Key.conditionalGetInfo] = conditionalGetInfo.dictionary
}
return d
} }
if let homePageURL = homePageURL {
d[Key.homePageURL] = homePageURL
}
if let iconURL = iconURL {
d[Key.iconURL] = iconURL
}
if let faviconURL = faviconURL {
d[Key.faviconURL] = faviconURL
}
if let name = name {
d[Key.name] = name
}
if let editedName = editedName {
d[Key.editedName] = editedName
}
if let authorsArray = authors?.diskArray() {
d[Key.authors] = authorsArray
}
if let contentHash = contentHash {
d[Key.contentHash] = contentHash
}
if unreadCount > 0 {
d[Key.unreadCount] = unreadCount
}
if let conditionalGetInfo = conditionalGetInfo {
d[Key.conditionalGetInfo] = conditionalGetInfo.dictionary
}
return d
} }
// MARK: - Debug // MARK: - Debug

View File

@ -110,9 +110,7 @@ extension Article: DatabaseObject {
} }
public var databaseID: String { public var databaseID: String {
get { return articleID
return articleID
}
} }
public func relatedObjectsWithName(_ name: String) -> [DatabaseObject]? { public func relatedObjectsWithName(_ name: String) -> [DatabaseObject]? {

View File

@ -26,9 +26,7 @@ extension ArticleStatus {
extension ArticleStatus: DatabaseObject { extension ArticleStatus: DatabaseObject {
public var databaseID: String { public var databaseID: String {
get { return articleID
return articleID
}
} }
public func databaseDictionary() -> NSDictionary? { public func databaseDictionary() -> NSDictionary? {

View File

@ -57,9 +57,7 @@ private func optionalIntForColumn(_ row: FMResultSet, _ columnName: String) -> I
extension Attachment: DatabaseObject { extension Attachment: DatabaseObject {
public var databaseID: String { public var databaseID: String {
get { return attachmentID
return attachmentID
}
} }
public func databaseDictionary() -> NSDictionary? { public func databaseDictionary() -> NSDictionary? {

View File

@ -45,9 +45,7 @@ extension Author {
extension Author: DatabaseObject { extension Author: DatabaseObject {
public var databaseID: String { public var databaseID: String {
get { return authorID
return authorID
}
} }
public func databaseDictionary() -> NSDictionary? { public func databaseDictionary() -> NSDictionary? {

View File

@ -13,12 +13,10 @@ import Data
extension ParsedItem { extension ParsedItem {
var articleID: String { var articleID: String {
get { if let s = syncServiceID {
if let s = syncServiceID { return s
return s
}
// Must be same calculation as for Article.
return Article.calculatedArticleID(feedID: feedURL, uniqueID: uniqueID)
} }
// Must be same calculation as for Article.
return Article.calculatedArticleID(feedID: feedURL, uniqueID: uniqueID)
} }
} }

View File

@ -179,9 +179,7 @@ private final class StatusCache {
var dictionary = [String: ArticleStatus]() var dictionary = [String: ArticleStatus]()
var cachedStatuses: Set<ArticleStatus> { var cachedStatuses: Set<ArticleStatus> {
get { return Set(dictionary.values)
return Set(dictionary.values)
}
} }
func add(_ statuses: Set<ArticleStatus>) { func add(_ statuses: Set<ArticleStatus>) {

View File

@ -27,8 +27,6 @@ public struct UnreadCountDictionary {
} }
public subscript(_ feed: Feed) -> Int? { public subscript(_ feed: Feed) -> Int? {
get { return dictionary[feed.feedID]
return dictionary[feed.feedID]
}
} }
} }

View File

@ -22,9 +22,7 @@ public final class BatchUpdate {
private var count = 0 private var count = 0
public var isPerforming: Bool { public var isPerforming: Bool {
get { return count > 0
return count > 0
}
} }
public func perform(_ batchUpdateBlock: BatchUpdateBlock) { public func perform(_ batchUpdateBlock: BatchUpdateBlock) {

View File

@ -11,15 +11,12 @@ import AppKit
public extension NSOutlineView { public extension NSOutlineView {
var selectedItems: [AnyObject] { var selectedItems: [AnyObject] {
get { if selectionIsEmpty {
return [AnyObject]()
}
if selectionIsEmpty { return selectedRowIndexes.compactMap { (oneIndex) -> AnyObject? in
return [AnyObject]() return item(atRow: oneIndex) as AnyObject
}
return selectedRowIndexes.compactMap { (oneIndex) -> AnyObject? in
return item(atRow: oneIndex) as AnyObject
}
} }
} }

View File

@ -11,9 +11,7 @@ import AppKit
public extension NSTableView { public extension NSTableView {
var selectionIsEmpty: Bool { var selectionIsEmpty: Bool {
get { return selectedRowIndexes.startIndex == selectedRowIndexes.endIndex
return selectedRowIndexes.startIndex == selectedRowIndexes.endIndex
}
} }
func indexesOfAvailableRowsPassingTest(_ test: (Int) -> Bool) -> IndexSet? { func indexesOfAvailableRowsPassingTest(_ test: (Int) -> Bool) -> IndexSet? {

View File

@ -52,9 +52,7 @@ struct RelatedObjectIDsMap {
} }
subscript(_ objectID: String) -> Set<String>? { subscript(_ objectID: String) -> Set<String>? {
get { return dictionary[objectID]
return dictionary[objectID]
}
} }
} }

View File

@ -39,8 +39,6 @@ public struct RelatedObjectsMap {
} }
public subscript(_ objectID: String) -> [DatabaseObject]? { public subscript(_ objectID: String) -> [DatabaseObject]? {
get { return dictionary[objectID]
return dictionary[objectID]
}
} }
} }

View File

@ -25,9 +25,7 @@ public struct FeedSpecifier: Hashable {
public let source: Source public let source: Source
public let hashValue: Int public let hashValue: Int
public var score: Int { public var score: Int {
get { return calculatedScore()
return calculatedScore()
}
} }
init(title: String?, urlString: String, source: Source) { init(title: String?, urlString: String, source: Source) {

View File

@ -14,9 +14,7 @@ private let feedURLWordsToMatch = ["feed", "xml", "rss", "atom", "json"]
class HTMLFeedFinder { class HTMLFeedFinder {
var feedSpecifiers: Set<FeedSpecifier> { var feedSpecifiers: Set<FeedSpecifier> {
get { return Set(feedSpecifiersDictionary.values)
return Set(feedSpecifiersDictionary.values)
}
} }
fileprivate var feedSpecifiersDictionary = [String: FeedSpecifier]() fileprivate var feedSpecifiersDictionary = [String: FeedSpecifier]()

View File

@ -21,46 +21,36 @@ public final class Node: Hashable {
private static var incrementingID = 0 private static var incrementingID = 0
public var isRoot: Bool { public var isRoot: Bool {
get { if let _ = parent {
if let _ = parent { return false
return false
}
return true
} }
return true
} }
public var numberOfChildNodes: Int { public var numberOfChildNodes: Int {
get { return childNodes?.count ?? 0
return childNodes?.count ?? 0
}
} }
public var indexPath: IndexPath { public var indexPath: IndexPath {
get { if let parent = parent {
if let parent = parent { let parentPath = parent.indexPath
let parentPath = parent.indexPath if let childIndex = parent.indexOfChild(self) {
if let childIndex = parent.indexOfChild(self) { return parentPath.appending(childIndex)
return parentPath.appending(childIndex)
}
preconditionFailure("A Nodes parent must contain it as a child.")
} }
return IndexPath(index: 0) //root node preconditionFailure("A Nodes parent must contain it as a child.")
} }
return IndexPath(index: 0) //root node
} }
public var level: Int { public var level: Int {
get { if let parent = parent {
if let parent = parent { return parent.level + 1
return parent.level + 1
}
return 0
} }
return 0
} }
public var isLeaf: Bool { public var isLeaf: Bool {
get { return numberOfChildNodes < 1
return numberOfChildNodes < 1
}
} }
public init(representedObject: AnyObject, parent: Node?) { public init(representedObject: AnyObject, parent: Node?) {

View File

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

View File

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

View File

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

View File

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

View File

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