-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rewrite of shootout-reverse-complement.rs #10799
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
rewrite of shootout-reverse-complement.rs #10799
Conversation
// reverse complement | ||
let mut seq = seq; | ||
loop { | ||
if seq.len() <= 1 {break;} |
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.
Why not while seq.len() > 1 { ... }
?
@huonw what do you think? |
if ch == 0 { | ||
break; | ||
// reverse complement | ||
let mut it = seq.mut_iter(); |
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 curious, but couldn't this whole loop be replaced with seq.reverse()
?
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.
It's reversing and transforming using complements
Equivalent but slower:
let mut it = seq.mut_iter();
loop {
match (it.next(), it.next_back()) {
(Some(front), Some(back)) => {
std::util::swap(front, back);
*front = complements[*front];
*back = complements[*back];
}
_ => break // vector exhausted.
}
}
Equivalent but much slower:
seq.reverse();
for c in seq.mut_iter() {
*c = complements[*c]
}
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.
Aha! I can totally read code.
Could you rebase these two commits into one? Other than that looks good to me! |
This version is inspired by the best version in C by Mr Ledrug, but without the parallelisation.
@alexcrichton squashed. |
…ected, r=alexcrichton This version is inspired by the best version in C by Mr Ledrug, but without the parallelisation.
This version is inspired by the best version in C by Mr Ledrug,
but without the parallelisation.