-
Notifications
You must be signed in to change notification settings - Fork 273
Optimize calls to increase_counter #3554
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
Optimize calls to increase_counter #3554
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me (but I'm not sure how much of an effect it actually has).
ae368be
to
1eb5181
Compare
} | ||
else | ||
state.level1.current_names.emplace( | ||
l0_name, std::make_pair(ssa, frame_nr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ Braces would be helpful here
@@ -38,10 +38,9 @@ struct symex_renaming_levelt | |||
} | |||
|
|||
/// Increase the counter corresponding to an identifier | |||
void increase_counter(const irep_idt &identifier) | |||
static void increase_counter(const current_namest::iterator &it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ Would have been better to create two different commits for these two changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure which two changes you are talking about
There was a problem hiding this 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: 1eb5181).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94207006
Taking an iterator instead of an identifier removes the need for a precondition (thus avoiding a lookup) and can avoid an additional lookup.
1eb5181
to
e71ca91
Compare
@tautschnig on my benchmarks the symex time went down by 9% |
There was a problem hiding this 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: e71ca91).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94218134
increase_counter
is always called after a lookup in the corresponding map, and performs two additional lookup, we can get rid of this redundancy by passing an iterator as argument.