-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: use Vec::with_capacity and reserve_exact #11904
perf: use Vec::with_capacity and reserve_exact #11904
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.
nice! in all of these cases, the vec is filled till capacity. if that were not the case, say if we would only push to the vec on some condition, you can just call my_vec.shrink_to_fit()
after the loop
2e19a75
to
ea14dc6
Compare
ea14dc6
to
1638722
Compare
|
||
// iterator over the chunks | ||
let chunks = tx_range | ||
.clone() | ||
.step_by(chunk_size) | ||
.map(|start| start..std::cmp::min(start + chunk_size as u64, tx_range.end)); | ||
let mut channels = Vec::with_capacity(tx_range_size.div_ceil(chunk_size)); |
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.
not sure if there is a better method to calculate channels capacity
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.
lgtm
No description provided.