|
Boost-Commit : |
From: technews_at_[hidden]
Date: 2007-12-30 15:16:42
Author: turkanis
Date: 2007-12-30 15:16:41 EST (Sun, 30 Dec 2007)
New Revision: 42378
URL: http://svn.boost.org/trac/boost/changeset/42378
Log:
ported changes from branches/iostreams_dev revisions 42356-42376:
fixed ticket #525:
detail/adapter/direct_adapter.hpp:
fixed ticket #822:
detail/adapter/direct_adapter.hpp:
detail/adapter/range_adapter.hpp
applied optimization from ticket #817:
detail/streambuf/indirect_streambuf.hpp
changed svn:keywords property:
test/large_file_test.cpp
Properties modified:
trunk/libs/iostreams/test/large_file_test.cpp (props changed)
Text files modified:
trunk/boost/iostreams/detail/adapter/direct_adapter.hpp | 15 ++++++++-------
trunk/boost/iostreams/detail/adapter/range_adapter.hpp | 6 +++---
trunk/boost/iostreams/detail/streambuf/indirect_streambuf.hpp | 9 +++++++++
3 files changed, 20 insertions(+), 10 deletions(-)
Modified: trunk/boost/iostreams/detail/adapter/direct_adapter.hpp
==============================================================================
--- trunk/boost/iostreams/detail/adapter/direct_adapter.hpp (original)
+++ trunk/boost/iostreams/detail/adapter/direct_adapter.hpp 2007-12-30 15:16:41 EST (Sun, 30 Dec 2007)
@@ -42,9 +42,10 @@
template<typename Direct>
class direct_adapter_base {
public:
- typedef typename char_type_of<Direct>::type char_type;
+ typedef typename char_type_of<Direct>::type char_type;
+ typedef typename mode_of<Direct>::type mode_type;
struct category
- : mode_of<Direct>::type,
+ : mode_type,
device_tag,
closable_tag
#ifndef BOOST_IOSTREAMS_NO_LOCALE
@@ -222,7 +223,7 @@
pointers& get = ptrs_.first();
pointers& put = ptrs_.second();
if (way == BOOST_IOS::cur && get.ptr != put.ptr)
- bad_seek();
+ throw bad_seek();
ptrdiff_t next = 0;
if ((which & BOOST_IOS::in) || !is_double::value) {
if (way == BOOST_IOS::beg)
@@ -231,10 +232,10 @@
next = get.ptr - get.beg + off;
else
next = get.end - get.beg + off;
- if (next >= 0 && next < get.end - get.beg)
+ if (next >= 0 && next <= get.end - get.beg)
get.ptr = get.beg + next;
else
- bad_seek();
+ throw bad_seek();
}
if ((which & BOOST_IOS::out) && is_double::value) {
if (way == BOOST_IOS::beg)
@@ -243,10 +244,10 @@
next = put.ptr - put.beg + off;
else
next = put.end - put.beg + off;
- if (next >= 0 && next < put.end - put.beg)
+ if (next >= 0 && next <= put.end - put.beg)
put.ptr = put.beg + next;
else
- bad_seek();
+ throw bad_seek();
}
return offset_to_position(next);
}
Modified: trunk/boost/iostreams/detail/adapter/range_adapter.hpp
==============================================================================
--- trunk/boost/iostreams/detail/adapter/range_adapter.hpp (original)
+++ trunk/boost/iostreams/detail/adapter/range_adapter.hpp 2007-12-30 15:16:41 EST (Sun, 30 Dec 2007)
@@ -155,18 +155,18 @@
using namespace std;
switch (way) {
case BOOST_IOS::beg:
- if (off > last - first || off < 0) bad_seek();
+ if (off > last - first || off < 0) throw bad_seek();
cur = first + off;
break;
case BOOST_IOS::cur:
{
std::ptrdiff_t newoff = cur - first + off;
- if (newoff > last - first || newoff < 0) bad_seek();
+ if (newoff > last - first || newoff < 0) throw bad_seek();
cur += off;
break;
}
case BOOST_IOS::end:
- if (last - first + off < 0 || off > 0) bad_seek();
+ if (last - first + off < 0 || off > 0) throw bad_seek();
cur = last + off;
break;
default:
Modified: trunk/boost/iostreams/detail/streambuf/indirect_streambuf.hpp
==============================================================================
--- trunk/boost/iostreams/detail/streambuf/indirect_streambuf.hpp (original)
+++ trunk/boost/iostreams/detail/streambuf/indirect_streambuf.hpp 2007-12-30 15:16:41 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,13 @@
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 obj().seek(0, BOOST_IOS::cur, BOOST_IOS::in, next_) -
+ static_cast<off_type>(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