-
Notifications
You must be signed in to change notification settings - Fork 48
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
PooledDictionary get fails with ValueTuple key #10
Comments
This appears to be more serious than I previously thought. It's not specific to ValueTuple keys. Instead, it appears to be any time there is more than 1 and less than 8 items in the dictionary, the lookup fails. |
The cause of this bug was an optimization I put into Resize: In this scenario, we're going from a capacity of 3 to a capacity of 7, but the underlying array we got from the ArrayPool is actually a 16-element array. In an attempt to short-circuit the "allocate new array, copy everything, and sort the entries into the new set of buckets" code, I failed to do the "sort the entries into the new set of buckets" part. Revised code skips over the "allocate new arrays and copy everything" part when the underlying array is large enough for the new capacity, but it now correctly sorts the entries into the new set of buckets, so lookups succeed when they should. |
* Reproduced issue in unit tests: a dictionary size of 4-7 causes failed lookups. * Fixes issue #10 * Updating possibly-affected benchmark results.
Describe the bug
Lookups fail in a
PooledDictionary<(int, int), string>
but succeed in aDictionary<(int, int), string>
.To Reproduce
Expected behavior
We should get the same results from both dictionary types, without having to specify custom comparers.
The text was updated successfully, but these errors were encountered: