Skip to content

Commit

Permalink
Avoid IEnumerable allocations when flusing data to sqlite.
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Nov 28, 2017
1 parent 32bc937 commit d4e1ecc
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,13 @@ private async Task FlushSpecificWritesAsync<TKey>(
// performed by FlushAllPendingWritesAsync.
using (await _writeQueueGate.DisposableWaitAsync(cancellationToken).ConfigureAwait(false))
{
// Get the writes we need to process.
writesToProcess.AddRange(keyToWriteActions[key]);
// Get the writes we need to process.
// Note: explicitly foreach so we operate on the struct enumerator for
// MultiDictionary.ValueSet.
foreach (var action in keyToWriteActions[key])
{
writesToProcess.Add(action);
}

// and clear them from the queues so we don't process things multiple times.
keyToWriteActions.Remove(key);
Expand Down

0 comments on commit d4e1ecc

Please sign in to comment.