-
Notifications
You must be signed in to change notification settings - Fork 2
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
Optimisations #32
Comments
Here are some optimisations that I have uncovered:
It could be better if we can update the function as follows: pub fn get_uniques(tpf_list: &[Tpf]) -> Vec<&String> {
let mut uniques = HashSet::new();
for tpf in tpf_list {
uniques.insert(&tpf.new_scaffold);
}
uniques.into_iter().collect()
} This will not copy values in-memory, as it will only use
pub fn subset_vec_tpf<'a>(
tpf: &'a [Tpf],
fasta: (&std::string::String, &usize),
) -> Vec<&'a Tpf> {
//
// Subset the Vec<TPF> based on a search through the fasta
//
tpf.iter().filter(|&i| i.ori_scaffold == *fasta.0).collect()
} |
let file = OpenOptions::new()
.read(true)
.write(true)
.create(true)
.open(output);
|
From
There's always box-types (Rust's equivalent to C++ smart pointers) which are there to allocate memory in the heap. Allocating extra stack space in the heap is a little unconventional. Stack is for allocating types that the compiler can identify the size of at compile time. Allocating something in the heap (e.g. recursive data structures like linked lists) incurs an additional overhead of a system signal to call a memory allocator but that is sort of a requirement to facilitate dynamically sized types such as vectors and strings. |
|
Now that we have started writing tests in #22, we could start adding some optimisations.
We can start optimisations with
src/tpf_fasta.rs
, as the file is being covered by tests, and is likely to be fully covered fairly soon.I will update this issue with comments when I discover any other optimisations possible.
The text was updated successfully, but these errors were encountered: