# HG changeset patch # User Mike Miller # Date 1349537035 14400 # Node ID c1c5b3cc29965a88c5629235acd8ee820cc61a4e # Parent d174210ce1ec47ce6eb4ecb3c723aa26b62a338e Avoid inefficient seeks in gzfilebuf (bug #37509) * src/zfstream.cc (gzfilebuf::seekoff): Avoid calling gzseek and invalidating buffers when not actually seeking. diff -r d174210ce1ec -r c1c5b3cc2996 src/zfstream.cc --- 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)