File tree Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -189,11 +189,8 @@ internal void Remove(Result result)
189189 }
190190
191191 // remove the record from the bag
192- var recordToRemove = value . FirstOrDefault ( r => r . Equals ( result ) ) ;
193- if ( recordToRemove != null )
194- {
195- value . TryTake ( out recordToRemove ) ;
196- }
192+ var bag = new ConcurrentQueue < Record > ( value . Where ( r => ! r . Equals ( result ) ) ) ;
193+ records [ result . OriginQuery . RawQuery ] = new ConcurrentBag < Record > ( bag ) ;
197194
198195 // if the bag is empty, remove the bag from the dictionary
199196 if ( value . IsEmpty )
@@ -230,21 +227,9 @@ internal void AddOrUpdate(Result result)
230227 else
231228 {
232229 // add or update the record in the bag
233- if ( value . Any ( r => r . Equals ( result ) ) )
234- {
235- // update the record
236- var recordToUpdate = value . FirstOrDefault ( r => r . Equals ( result ) ) ;
237- if ( recordToUpdate != null )
238- {
239- value . TryTake ( out recordToUpdate ) ;
240- value . Add ( record ) ;
241- }
242- }
243- else
244- {
245- // add the record
246- value . Add ( record ) ;
247- }
230+ var bag = new ConcurrentQueue < Record > ( value . Where ( r => ! r . Equals ( result ) ) ) ; // make sure we don't have duplicates
231+ bag . Enqueue ( record ) ;
232+ records [ result . OriginQuery . RawQuery ] = new ConcurrentBag < Record > ( bag ) ;
248233 }
249234 }
250235 }
You can’t perform that action at this time.
0 commit comments