Skip to content

Commit

Permalink
Add make_randstrobe function
Browse files Browse the repository at this point in the history
Reduces code duplication a little bit.
  • Loading branch information
marcelm committed Oct 1, 2024
1 parent 30d38de commit 30cd10f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/randstrobes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ std::ostream& operator<<(std::ostream& os, const QueryRandstrobe& randstrobe) {
return os;
}

Randstrobe make_randstrobe(Syncmer strobe1, Syncmer strobe2) {
return Randstrobe{
randstrobe_hash(strobe1.hash, strobe2.hash),
static_cast<uint32_t>(strobe1.position),
static_cast<uint32_t>(strobe2.position)
};
}

Randstrobe RandstrobeIterator::get(unsigned int strobe1_index) const {
unsigned int w_end = std::min(static_cast<size_t>(strobe1_index + w_max), syncmers.size() - 1);

Expand All @@ -167,7 +175,7 @@ Randstrobe RandstrobeIterator::get(unsigned int strobe1_index) const {
}
}

return Randstrobe{randstrobe_hash(strobe1.hash, strobe2.hash), static_cast<uint32_t>(strobe1.position), static_cast<uint32_t>(strobe2.position)};
return make_randstrobe(strobe1, strobe2);
}

Randstrobe RandstrobeGenerator::next() {
Expand Down Expand Up @@ -198,7 +206,8 @@ Randstrobe RandstrobeGenerator::next() {
}
}
syncmers.pop_front();
return Randstrobe{randstrobe_hash(strobe1.hash, strobe2.hash), static_cast<uint32_t>(strobe1.position), static_cast<uint32_t>(strobe2.position)};

return make_randstrobe(strobe1, strobe2);
}

/*
Expand Down

0 comments on commit 30cd10f

Please sign in to comment.