Skip to content

Commit

Permalink
Improves performance of remove_eov().
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonl committed Dec 3, 2023
1 parent 8ce2f31 commit 608b504
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/unique_haplotype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,19 @@ int unique_haplotype_block::deserialize(savvy::reader& input_file, savvy::varian

void unique_haplotype_block::remove_eov()
{
for (auto it = unique_map_.begin(); it != unique_map_.end(); )
std::size_t eov_cnt = 0;
auto it = unique_map_.begin();
auto dest_it = it;
for ( ; it != unique_map_.end(); ++it)
{
if (savvy::typed_value::is_end_of_vector(*it))
it = unique_map_.erase(it);
++eov_cnt;
else
++it;
*(dest_it++) = *it;
}

if (eov_cnt)
unique_map_.resize(unique_map_.size() - eov_cnt);
}

bool unique_haplotype_block::deserialize(std::istream& is, int m3vcf_version, std::size_t n_haplotypes)
Expand Down Expand Up @@ -547,4 +553,4 @@ float reduced_haplotypes::compression_ratio() const
}

return num / denom;
}
}

0 comments on commit 608b504

Please sign in to comment.