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
[SR-9870] Dictionary needs an API suitable for memoization #52276
Comments
This works but doesn't really invalidate your request.
|
cc @lorentey |
@belkadan That is truly evil. Have to say I'm impressed! |
Yeah, this shouldn't need such contortions. A direct implementation would generate better code. The good news is that Jordan's evil version only hashes twice on the slow path, when the insertion needs to resize the table. (In which case rehashing is necessary, as the dictionary switches to a new hash seed.) Given that we already have a defaulting subscript with slightly different semantics, memoization would probably work better as a mutating method than a new subscript variant.
(I am not attached to this particular method name or signature, though.) |
Attachment: Download
Additional Detail from JIRA
md5: d2bb9e67d575089c4ebdf00102db57df
Issue Description:
We need an API like this:
There's no way to code it outside the standard library that avoids doing a 2nd dictionary lookup.
The text was updated successfully, but these errors were encountered: