-
Notifications
You must be signed in to change notification settings - Fork 27
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
perf: BTreeMap: make range().count()
more efficient
#190
perf: BTreeMap: make range().count()
more efficient
#190
Conversation
range().count()
more efficientrange().count()
more efficient
@ielashi I can add a benchmark to compare it with the previous implementation, but I am not sure that is important. WDYT? |
It is absolutely important :) How else will we know that our change has improved anything? |
@ielashi The bench is added:) |
Co-authored-by: Islam El-Ashi <islam.elashi@dfinity.org>
…ange-count-more-efficient
…into Add_iter_count_benches
…ange-count-more-efficient
range().count()
more efficientrange().count()
more efficient
range().count()
more efficientrange().count()
more efficient
range().count()
more efficientrange().count()
more efficient
|
Co-authored-by: Islam El-Ashi <islam.elashi@dfinity.org>
Problem:
BTreeMap::Iterator::count() implicitly uses BTreeMap::Iterator::next() which in some cases loads the map entry's value non-lazy.
Solution:
Explicitly reimplement BTreeMap::Iterator::count() so it does not load the value.