Skip to content

Commit

Permalink
fix: remove hack for clang
Browse files Browse the repository at this point in the history
  • Loading branch information
SGSSGene committed May 9, 2023
1 parent 12d9b3a commit 8a1e0df
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/fmindex-collection/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ auto createSequences(Sequences auto const& _input, int samplingRate, bool revers
// compute total numbers of bytes of the text including delimiters "$"
size_t totalSize{};
for (auto const& l : _input) {
auto textLen = l.size();
auto textLen = l.size();
auto delimLen = samplingRate - textLen % samplingRate; // Make sure it is always a multiple of samplingRate
totalSize += textLen + delimLen;
}
Expand All @@ -62,25 +62,20 @@ auto createSequences(Sequences auto const& _input, int samplingRate, bool revers

for (auto const& l : _input) {
auto ls = l.size();

inputText.insert(inputText.end(), begin(l), end(l));
if (reverse) {
std::reverse(inputText.end()-ls, inputText.end());
}

// number of delimiters ('$') which need to be added. It must be at least one, and it
// has to make sure the text will be a multiple of samplingRate
size_t delimCount = samplingRate - (ls % samplingRate);
inputText.resize(inputText.size() + ls + delimCount, 0);

if (not reverse) {
std::ranges::copy(l, end(inputText) - ls - delimCount);
} else {
//!TODO hack for clang, broken in clang 15
#if __clang__
auto l2 = std::vector<uint8_t>(l);
std::ranges::reverse(l2);
#else
auto l2 = std::views::reverse(l);
#endif
std::ranges::copy(l2, end(inputText) - ls - delimCount);
}

inputSizes.emplace_back(l.size(), delimCount);
// fill with delimiters/zeros
inputText.resize(inputText.size() + delimCount);

inputSizes.emplace_back(ls, delimCount);
}
return {totalSize, inputText, inputSizes};
}
Expand Down

0 comments on commit 8a1e0df

Please sign in to comment.