Skip to content

Change erase() method of the sharing map to require that key exists #4484

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

Merged
merged 1 commit into from
Apr 4, 2019

Conversation

danpoe
Copy link
Contributor

@danpoe danpoe commented Apr 4, 2019

Previously when sharing_map.erase(key) was called, two traversals of the path to the leaf to erase were done. One to check whether the key was in the map, and if it was, a second one to copy and detach the nodes on the path to the leaf. This commit changes erase() to require that the given key exists in the map. This simplifies the implementation and avoids two traversals of the path to the leaf when it is known that the key exists. If it is not known whether the key exists, sharing_map.has_key(key) should be explicitely called first.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@danpoe
Copy link
Contributor Author

danpoe commented Apr 4, 2019

@tautschnig This will require wrapping the calls propagation.erase(key) in #4464 by if(propagation.has_key(key)) if it is not known whether the key exists.

…y exists

Previously when sharing_map.erase(key) was called, two traversals of the path to
the leaf to erase were done. One to check whether the key was in the map, and if
it was, a second one to copy and detach the nodes on the path to the leaf to
erase. This commit changes erase() to require that the given key exists in the
map. This simplifies the implementation and avoids two traversals of the path to
the leaf to erase when it is known that the key exists. If it is not known
whether the key exists, sharing_map.has_key(key) should be explicitely called
first.
@danpoe danpoe force-pushed the refactor/sharing-map-erase branch from 4d0c932 to b2a548c Compare April 4, 2019 14:41
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: b2a548c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107095440

@tautschnig tautschnig merged commit 5b9df9b into diffblue:develop Apr 4, 2019
@tautschnig
Copy link
Collaborator

This will require wrapping the calls propagation.erase(key) in #4464 by if(propagation.has_key(key)) if it is not known whether the key exists.

Thanks a lot for the heads-up, now done (also in the field-sensitivity PR).

@danpoe danpoe deleted the refactor/sharing-map-erase branch June 2, 2020 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants