Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 2585f2c

Browse files
authored
Faster label summary equality for diffing (#725)
* Faster label summary equality for diffing * actually build & fix errors
1 parent 50b8116 commit 2585f2c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Classes/Repository/RepositoryIssueSummaryModel.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class RepositoryIssueSummaryModel: ListDiffable {
2020
let pullRequest: Bool
2121
let labels: [RepositoryLabel]
2222

23+
// quicker comparison for diffing rather than scanning the labels array
24+
private let labelSummary: String
25+
2326
init(
2427
id: String,
2528
title: NSAttributedStringSizing,
@@ -38,6 +41,7 @@ class RepositoryIssueSummaryModel: ListDiffable {
3841
self.status = status
3942
self.pullRequest = pullRequest
4043
self.labels = labels
44+
self.labelSummary = labels.reduce("", { $0 + $1.name })
4145
}
4246

4347
// MARK: ListDiffable
@@ -56,6 +60,6 @@ class RepositoryIssueSummaryModel: ListDiffable {
5660
&& author == object.author
5761
&& created == object.created
5862
&& title.attributedText.string == object.title.attributedText.string
59-
&& labels == object.labels
63+
&& labelSummary == object.labelSummary
6064
}
6165
}

0 commit comments

Comments
 (0)