Skip to content

Commit e5c0340

Browse files
committed
spanstream: implement xsgetn
It's much faster!
1 parent a194154 commit e5c0340

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/spanstream.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ class spanstream : public std::istream
4444
}
4545
}
4646

47+
std::streamsize xsgetn(char *s, std::streamsize n) override {
48+
if (position + n <= buffer_size) {
49+
std::copy(buffer + position, buffer + position + n, s);
50+
position += n;
51+
return n;
52+
}
53+
return 0;
54+
}
55+
4756
int_type underflow() override {
4857
return (position < buffer_size) ? buffer[position] : traits_type::eof();
4958
}

0 commit comments

Comments
 (0)