Skip to content

Commit fe50948

Browse files
zlib_wrapper: Change to make reading a line slightly more efficient
1 parent 9df8c3e commit fe50948

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

zlib_wrapper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ igzfstream&
3131
getline(igzfstream &in, string &line) {
3232
if (gzgets(in.fileobj, &in.buf[0], in.chunk_size)) {
3333
auto eol = std::find(begin(in.buf), end(in.buf), '\n');
34-
line = string(begin(in.buf), eol);
34+
line.clear();
35+
// in case line already has a reserve
36+
copy(begin(in.buf), eol, std::back_inserter(line));
3537
}
3638
return in;
3739
}

0 commit comments

Comments
 (0)