Skip to content

Commit 58b9f0c

Browse files
committed
Improve remove logic
1 parent c49b3b7 commit 58b9f0c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Flow.Launcher/Storage/TopMostRecord.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,16 @@ internal void Remove(Result result)
190190

191191
// remove the record from the bag
192192
var bag = new ConcurrentQueue<Record>(value.Where(r => !r.Equals(result)));
193-
records[result.OriginQuery.RawQuery] = new ConcurrentBag<Record>(bag);
194-
195-
// if the bag is empty, remove the bag from the dictionary
196-
if (value.IsEmpty)
193+
if (bag.IsEmpty)
197194
{
195+
// if the bag is empty, remove the bag from the dictionary
198196
records.TryRemove(result.OriginQuery.RawQuery, out _);
199197
}
198+
else
199+
{
200+
// change the bag in the dictionary
201+
records[result.OriginQuery.RawQuery] = new ConcurrentBag<Record>(bag);
202+
}
200203
}
201204

202205
internal void AddOrUpdate(Result result)

0 commit comments

Comments
 (0)