Skip to content

Commit 51a16cc

Browse files
taoocerosVictoriousRaptor
authored andcommitted
Remove Result comparison and Change signature from IEnumerable to ICollection (due to the potential of multiple enumeration)
1 parent 3d8cf29 commit 51a16cc

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
@@ -157,27 +157,6 @@ public string PluginDirectory
157157
}
158158
}
159159

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

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)