Boost logo

Boost-Commit :

From: chris_at_[hidden]
Date: 2008-04-20 21:39:07


Author: chris_kohlhoff
Date: 2008-04-20 21:39:06 EDT (Sun, 20 Apr 2008)
New Revision: 44666
URL: http://svn.boost.org/trac/boost/changeset/44666

Log:
Improve efficiency of basic_streambuf::consume() by using a single call to
gbump() rather than calling sbumpc() in a loop.

Text files modified:
   trunk/boost/asio/basic_streambuf.hpp | 8 +++-----
   1 files changed, 3 insertions(+), 5 deletions(-)

Modified: trunk/boost/asio/basic_streambuf.hpp
==============================================================================
--- trunk/boost/asio/basic_streambuf.hpp (original)
+++ trunk/boost/asio/basic_streambuf.hpp 2008-04-20 21:39:06 EDT (Sun, 20 Apr 2008)
@@ -101,11 +101,9 @@
   /// Move the start of the get area by the specified number of characters.
   void consume(std::size_t n)
   {
- while (n > 0)
- {
- sbumpc();
- --n;
- }
+ if (gptr() + n > pptr())
+ n = pptr() - gptr();
+ gbump(static_cast<int>(n));
   }
 
 protected:


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