Faster label summary equality for diffing (#725)

* Faster label summary equality for diffing

* actually build & fix errors
This commit is contained in:
Ryan Nystrom
2017-10-24 21:58:59 -04:00
committed by GitHub
parent 50b811667d
commit 2585f2c39a

View File

@@ -20,6 +20,9 @@ class RepositoryIssueSummaryModel: ListDiffable {
let pullRequest: Bool
let labels: [RepositoryLabel]
// quicker comparison for diffing rather than scanning the labels array
private let labelSummary: String
init(
id: String,
title: NSAttributedStringSizing,
@@ -38,6 +41,7 @@ class RepositoryIssueSummaryModel: ListDiffable {
self.status = status
self.pullRequest = pullRequest
self.labels = labels
self.labelSummary = labels.reduce("", { $0 + $1.name })
}
// MARK: ListDiffable
@@ -56,6 +60,6 @@ class RepositoryIssueSummaryModel: ListDiffable {
&& author == object.author
&& created == object.created
&& title.attributedText.string == object.title.attributedText.string
&& labels == object.labels
&& labelSummary == object.labelSummary
}
}