Improve remove logic

This commit is contained in:
Jack251970 2025-05-01 13:47:35 +08:00
parent c49b3b7cba
commit 58b9f0c19c

View file

@ -190,13 +190,16 @@ namespace Flow.Launcher.Storage
// remove the record from the bag // remove the record from the bag
var bag = new ConcurrentQueue<Record>(value.Where(r => !r.Equals(result))); var bag = new ConcurrentQueue<Record>(value.Where(r => !r.Equals(result)));
records[result.OriginQuery.RawQuery] = new ConcurrentBag<Record>(bag); if (bag.IsEmpty)
// if the bag is empty, remove the bag from the dictionary
if (value.IsEmpty)
{ {
// if the bag is empty, remove the bag from the dictionary
records.TryRemove(result.OriginQuery.RawQuery, out _); records.TryRemove(result.OriginQuery.RawQuery, out _);
} }
else
{
// change the bag in the dictionary
records[result.OriginQuery.RawQuery] = new ConcurrentBag<Record>(bag);
}
} }
internal void AddOrUpdate(Result result) internal void AddOrUpdate(Result result)