Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #1217 #1426

Merged
merged 1 commit into from
Nov 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/EntityFramework/Core/Query/InternalTrees/VarVec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -843,11 +843,11 @@ private static int GetArraySize(int n, int div)

private class ArrayPool
{
private Dictionary<int, ConcurrentBag<int[]>> dictionary;
private ConcurrentDictionary<int, ConcurrentBag<int[]>> dictionary;

private ArrayPool()
{
dictionary = new Dictionary<int, ConcurrentBag<int[]>>();
dictionary = new ConcurrentDictionary<int, ConcurrentBag<int[]>>();
}

private static readonly ArrayPool instance = new ArrayPool();
Expand All @@ -872,17 +872,7 @@ public int[] GetArray(int length)

private ConcurrentBag<int[]> GetBag(int length)
{
ConcurrentBag<int[]> arrays;
if (!dictionary.ContainsKey(length))
{
arrays = new ConcurrentBag<int[]>();
dictionary[length] = arrays;
}
else
{
arrays = dictionary[length];
}
return arrays;
return dictionary.GetOrAdd(length, l => new ConcurrentBag<int[]>());
}

public void PutArray(int[] arr)
Expand Down