This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Simplify slightly basic_filebuf::xsgetn
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Cc: bkoz <bkoz at redhat dot com>
- Date: Sun, 01 Jun 2003 13:42:57 +0200
- Subject: [Patch] Simplify slightly basic_filebuf::xsgetn
Hi.
Minor simplifications consistent with the pback clean up.
Tested x86-linux. Ok with you?
Paolo.
//////
2003-06-01 Paolo Carlini <pcarlini@unitus.it>
* include/std/std_fstream.h (_M_destroy_pback): Use _M_in_beg
instead of unnecessarily taking the address of _M_pback.
(xsgetn): Simplify slightly for a single char pback buffer.
diff -urN libstdc++-v3-2/include/std/std_fstream.h libstdc++-v3/include/std/std_fstream.h
--- libstdc++-v3-2/include/std/std_fstream.h 2003-05-29 13:02:27.000000000 +0200
+++ libstdc++-v3/include/std/std_fstream.h 2003-06-01 13:25:44.000000000 +0200
@@ -191,7 +191,7 @@
if (_M_pback_init)
{
// Length _M_in_cur moved in the pback buffer.
- const size_t __off = this->_M_in_cur == &_M_pback ? 0 : 1;
+ const size_t __off = this->_M_in_cur == this->_M_in_beg ? 0 : 1;
this->setg(this->_M_buf, _M_pback_cur_save + __off,
_M_pback_end_save);
_M_pback_init = false;
@@ -399,12 +399,10 @@
// Clear out pback buffer before going on to the real deal...
if (this->_M_pback_init)
{
- while (__ret < __n && this->_M_in_cur < this->_M_in_end)
+ if (__n && this->_M_in_cur == this->_M_in_beg)
{
- *__s = *this->_M_in_cur;
- ++__ret;
- ++__s;
- ++this->_M_in_cur;
+ *__s++ = *this->_M_in_cur++;
+ __ret = 1;
}
_M_destroy_pback();
}