-
Notifications
You must be signed in to change notification settings - Fork 5
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
Dev bp clippy #18
base: dev_bp
Are you sure you want to change the base?
Dev bp clippy #18
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.
A few changes are too eager, as they destroy test coverage
@@ -213,14 +213,14 @@ fn test_custom_iter_behavior() { | |||
assert!(iter.advance_by(6).is_err()); | |||
assert!(iter.advance_back_by(5).is_ok()); | |||
|
|||
assert_eq!(bv.iter().skip(2).next(), Some(0)); |
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.
Please revert this and suppress the clippy correction. This intentionally calls skip() and next() to verify skip behaves correctly. This test should exist regardless of whether nth() internally uses skip (which I think it doesn't). Same for the change a few lines down.
} | ||
} | ||
|
||
#[test] | ||
fn test_custom_iter_behavior() { | ||
let ef = EliasFanoVec::from_slice(&vec![0, 1, 2, 3, 4, 5, 6, 7, 8]); | ||
assert_eq!(ef.iter().skip(2).next(), Some(2)); |
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.
Same here: skip().next() is called intentionally to test the skip function over nth(). Same a few lines below.
@@ -94,8 +94,8 @@ impl WaveletMatrix { | |||
|
|||
for (level, data) in data.iter_mut().enumerate() { | |||
let mut total_zeros = 0; | |||
for i in 0..num_elements { | |||
if bit_lookup(permutation[i], element_len - level - 1) == 0 { | |||
for (i, p) in permutation.iter().enumerate().take(num_elements) { |
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.
is take() required here? is i
required here?
Here's a draft PR applying suggested clippy changes to the dev_bp branch to make
cargo clippy
produce no output and besides that I tried to follow clippy suggestions in tests and benches.Many of the clippy changes are in tests. A lot of them have to do with changing manual indexing to using iterators, or not using
vec!
for sample data.In main code:
I noticed that unfortunately there are some spurious diffs due to whitespace changes - I only use the standard Rust formatter though. I think that's mostly restricted to the new trees module. Most of the clippy changes in the trees section involve changing
and_then
intomap
and a few redundant closures.div_ceil
is an interesting one; there were various cases where it was implemented manually. There are a few changes of manual indexing to iter() in the wavelet matrix code.I am curious whether there is any performance impact; I haven't done a benchmark compare yet.
Finally one change that seems silly: the additional brackets are what clippy suggests though they seem entirely redundant here.