Mercurial > octave-nkf
diff src/zfstream.cc @ 15510:c1c5b3cc2996 stable
Avoid inefficient seeks in gzfilebuf (bug #37509)
* src/zfstream.cc (gzfilebuf::seekoff): Avoid calling gzseek and
invalidating buffers when not actually seeking.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Sat, 06 Oct 2012 11:23:55 -0400 |
parents | 72c96de7a403 |
children |
line wrap: on
line diff
--- a/src/zfstream.cc Mon Oct 01 17:18:49 2012 -0400 +++ b/src/zfstream.cc Sat Oct 06 11:23:55 2012 -0400 @@ -473,6 +473,11 @@ if ((io_mode & std::ios_base::in) && way == std::ios_base::cur) computed_off += this->gptr() - this->egptr(); + // Handle tellg/tellp as a special case up front, no need to seek + // or invalidate get/put buffers + if (off == 0 && way == std::ios_base::cur) + return pos_type (gztell (file) + computed_off); + if (way == std::ios_base::beg) ret = pos_type (gzseek (file, computed_off, SEEK_SET)); else if (way == std::ios_base::cur)