Boost logo

Boost-Commit :

From: technews_at_[hidden]
Date: 2007-12-30 04:42:26


Author: turkanis
Date: 2007-12-30 04:42:26 EST (Sun, 30 Dec 2007)
New Revision: 42367
URL: http://svn.boost.org/trac/boost/changeset/42367

Log:
applied patch from ticket #817, with modifications
Text files modified:
   branches/iostreams_dev/boost/iostreams/detail/streambuf/indirect_streambuf.hpp | 11 +++++++++++
   1 files changed, 11 insertions(+), 0 deletions(-)

Modified: branches/iostreams_dev/boost/iostreams/detail/streambuf/indirect_streambuf.hpp
==============================================================================
--- branches/iostreams_dev/boost/iostreams/detail/streambuf/indirect_streambuf.hpp (original)
+++ branches/iostreams_dev/boost/iostreams/detail/streambuf/indirect_streambuf.hpp 2007-12-30 04:42:26 EST (Sun, 30 Dec 2007)
@@ -7,6 +7,8 @@
 // A. Langer and K. Kreft, "Standard C++ IOStreams and Locales",
 // Addison-Wesley, 2000, pp. 228-43.
 
+// User "GMSB" provided an optimization for small seeks.
+
 #ifndef BOOST_IOSTREAMS_DETAIL_INDIRECT_STREAMBUF_HPP_INCLUDED
 #define BOOST_IOSTREAMS_DETAIL_INDIRECT_STREAMBUF_HPP_INCLUDED
 
@@ -340,6 +342,15 @@
 indirect_streambuf<T, Tr, Alloc, Mode>::seek_impl
     (stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
 {
+ if ( gptr() != 0 && way == BOOST_IOS::cur && which == BOOST_IOS::in &&
+ eback() - gptr() <= off && off <= egptr() - gptr() )
+ { // Small seek optimization
+ gbump(off);
+ return offset_to_position(
+ obj().seek(0, BOOST_IOS::cur, BOOST_IOS::in, next_) -
+ static_cast<std::streamoff>(egptr() - gptr())
+ );
+ }
     if (pptr() != 0)
         this->BOOST_IOSTREAMS_PUBSYNC(); // sync() confuses VisualAge 6.
     if (way == BOOST_IOS::cur && gptr())


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk