Skip to content

Commit 41a345a

Browse files
committed
Remove Result comparison and Change signature from IEnumerable to ICollection (due to the potential of multiple enumeration)
1 parent 14f1a5a commit 41a345a

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -156,27 +156,6 @@ public string PluginDirectory
156156
}
157157
}
158158

159-
/// <inheritdoc />
160-
public override bool Equals(object obj)
161-
{
162-
var r = obj as Result;
163-
164-
var equality = string.Equals(r?.Title, Title) &&
165-
string.Equals(r?.SubTitle, SubTitle) &&
166-
string.Equals(r?.AutoCompleteText, AutoCompleteText) &&
167-
string.Equals(r?.CopyText, CopyText) &&
168-
string.Equals(r?.IcoPath, IcoPath) &&
169-
TitleHighlightData == r.TitleHighlightData;
170-
171-
return equality;
172-
}
173-
174-
/// <inheritdoc />
175-
public override int GetHashCode()
176-
{
177-
return HashCode.Combine(Title, SubTitle, AutoCompleteText, CopyText, IcoPath);
178-
}
179-
180159
/// <inheritdoc />
181160
public override string ToString()
182161
{

Flow.Launcher/ViewModel/ResultsViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public void AddResults(List<Result> newRawResults, string resultId)
182182
/// <summary>
183183
/// To avoid deadlock, this method should not called from main thread
184184
/// </summary>
185-
public void AddResults(IEnumerable<ResultsForUpdate> resultsForUpdates, CancellationToken token, bool reselect = true)
185+
public void AddResults(ICollection<ResultsForUpdate> resultsForUpdates, CancellationToken token, bool reselect = true)
186186
{
187187
var newResults = NewResults(resultsForUpdates);
188188

@@ -228,12 +228,12 @@ private List<ResultViewModel> NewResults(List<Result> newRawResults, string resu
228228
.ToList();
229229
}
230230

231-
private List<ResultViewModel> NewResults(IEnumerable<ResultsForUpdate> resultsForUpdates)
231+
private List<ResultViewModel> NewResults(ICollection<ResultsForUpdate> resultsForUpdates)
232232
{
233233
if (!resultsForUpdates.Any())
234234
return Results;
235235

236-
return Results.Where(r => r != null && !resultsForUpdates.Any(u => u.ID == r.Result.PluginID))
236+
return Results.Where(r => r != null && resultsForUpdates.All(u => u.ID != r.Result.PluginID))
237237
.Concat(resultsForUpdates.SelectMany(u => u.Results, (u, r) => new ResultViewModel(r, _settings)))
238238
.OrderByDescending(rv => rv.Result.Score)
239239
.ToList();

0 commit comments

Comments
 (0)