Skip to content

Commit

Permalink
[MISC] Make operator>> not O(n^2)
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Jul 8, 2019
1 parent daa9d7c commit 8d0fd8e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/seqan3/range/container/dynamic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,12 +1422,16 @@ class dynamic_bitset
? std::min<std::streamsize>(is.width(), arg.max_size())
: arg.max_size();
assert(num_char > 0);
std::vector<bool> tmp{};
tmp.reserve(num_char);
for (std::streamsize n = num_char; n > 0 && (is.peek() == is.widen('0') || is.peek() == is.widen('1')); --n)
{
char c = is.get();
c == is.widen('0') ? arg.insert(arg.cbegin(), false) : arg.insert(arg.cbegin(), true);
c == is.widen('0') ? tmp.push_back(false) : tmp.push_back(true);
}

arg.assign(std::view::reverse(tmp));

if (arg.size() == 0) // nothing extracted so we set the fail bit.
is.setstate(std::ios_base::failbit);

Expand Down

0 comments on commit 8d0fd8e

Please sign in to comment.