-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.CollectionsenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionstenet-performancePerformance related issuePerformance related issue
Milestone
Description
Keeping a list of changes made in DictionarySlim that could benefit Dictionary
- Instead of
& 0x7FFFFFFF;
to remove the sign bit on the hash code, use(uint)
cast and store a uint hashcode, retaining more entropy. To store 'empty' instead of hashcode of -1 use this scheme:
// 0-based index of next entry in chain: -1 means end of chain
// also encodes whether this entry _itself_ is part of the free list by changing sign and subtracting 3,
// so -2 means end of free list, -3 means index 0 but on free list, -4 means index 1 but on free list, etc.
public int next;
- Eliminate the
_freeCount
field and use_freeList == -1
as a sentinel instead Eliminate_buckets == null
check on every access, use a dummy 1-element array instead, on which reads fail and adds cause a resize into a real array
Some of these apply to HashSet<T>
also.
TylerBrinkley
Metadata
Metadata
Assignees
Labels
area-System.CollectionsenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionstenet-performancePerformance related issuePerformance related issue