Skip to content

Commit

Permalink
ipts: Simplify reading to a span of bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
StollD committed Apr 29, 2023
1 parent d9814da commit f99a2e6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/ipts/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <gsl/gsl>

#include <algorithm>

namespace iptsd::ipts {

class Reader {
Expand All @@ -29,14 +31,8 @@ class Reader {
if (dest.size() > this->size())
throw std::runtime_error("Tried to read more data than available!");

auto begin = m_data.begin();
std::advance(begin, m_index);

auto end = begin;
std::advance(end, dest.size());

std::copy(begin, end, dest.begin());
m_index += dest.size();
const gsl::span<u8> src = this->subspan(dest.size());
std::copy(src.begin(), src.end(), dest.begin());
}

/*!
Expand Down

0 comments on commit f99a2e6

Please sign in to comment.