Mercurial > hg > octave-lyh
changeset 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 | d174210ce1ec |
children | dcd6fa8d3da2 |
files | src/zfstream.cc |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/zfstream.cc +++ b/src/zfstream.cc @@ -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)