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

Allocate WeakKeyDictionary`2 with smaller initial capacities #222

Merged
merged 1 commit into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ internal class Helper
/// <summary>
/// A map of resources to the tasks that most recently began evaluating them.
/// </summary>
private WeakKeyDictionary<TResource, ResourcePreparationTaskAndValidity> resourcePreparationTasks = new WeakKeyDictionary<TResource, ResourcePreparationTaskAndValidity>();
private WeakKeyDictionary<TResource, ResourcePreparationTaskAndValidity> resourcePreparationTasks = new WeakKeyDictionary<TResource, ResourcePreparationTaskAndValidity>(capacity: 2);

/// <summary>
/// Initializes a new instance of the <see cref="Helper"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public class JoinableTaskCollection : IEnumerable<JoinableTask>
/// The value is the number of times the joinable was added to this collection (and not yet removed)
/// if this collection is ref counted; otherwise the value is always 1.
/// </summary>
private readonly WeakKeyDictionary<JoinableTask, int> joinables = new WeakKeyDictionary<JoinableTask, int>();
private readonly WeakKeyDictionary<JoinableTask, int> joinables = new WeakKeyDictionary<JoinableTask, int>(capacity: 2);

/// <summary>
/// The set of joinable tasks that have Joined this collection -- that is, the set of joinable tasks that are interested
/// in the completion of any and all joinable tasks that belong to this collection.
/// The value is the number of times a particular joinable task has Joined this collection.
/// </summary>
private readonly WeakKeyDictionary<JoinableTask, int> joiners = new WeakKeyDictionary<JoinableTask, int>();
private readonly WeakKeyDictionary<JoinableTask, int> joiners = new WeakKeyDictionary<JoinableTask, int>(capacity: 2);

/// <summary>
/// A value indicating whether joinable tasks are only removed when completed or removed as many times as they were added.
Expand Down