Replace a misuse prone internal API with a better one.#565
Merged
Conversation
`occupied_entry` was documented as not being useful for `insert`, but ok for setting various marks. This is because `OccupiedEntry` combines insertion with lookup by returning the previous value. In doing so it assumes that the previous value exists, where in the case of the `occupied_entry` function called from a `VacantEntry` there was no previous value. Instead this patch just adds the various marking functions to `VacantEntry` avoiding the problematic assumptions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
occupied_entrywas documented as not being useful forinsert, but ok for setting various marks. This is becauseOccupiedEntrycombines insertion with lookup by returning the previous value. In doing so it assumes that the previous value exists, where in the case of theoccupied_entryfunction called from aVacantEntrythere was no previous value.Instead this patch just adds the various marking functions to
VacantEntryavoiding the problematic assumptions.I didn't add
mark_used, because it seems out of place and sequence, marking as used is typically done late after lookup, not early before insertion. Oddly the tests domark_usedearly, but only because they needed an extra mark to cover all the internal states of theVacantEntryfieldposI did addset_merge_behavioreven though it isn't used, because at least with that I can think of uses for it.