streambuf.tcc (basic_streambuf::xsgetn): Const-ify some variables.

2003-05-01  Paolo Carlini  <pcarlini@unitus.it>

	* include/bits/streambuf.tcc (basic_streambuf::xsgetn):
	Const-ify some variables.
	(basic_streambuf::xsputn): Likewise; change the type of some
	variables to size_t.
	(__copy_streambufs): Change some variables to size_t.

2003-05-01  Paolo Carlini  <pcarlini@unitus.it>

	* include/std/std_sstream.h (str()): Avoid constructing
	a basic_string temporary not only when it would turn out
	to be zero-sized but also when identical to the current
	_M_string buffer.

From-SVN: r66334
This commit is contained in:
Paolo Carlini 2003-05-01 18:45:50 +02:00 committed by Paolo Carlini
parent d479d37f5e
commit 397751aef0
3 changed files with 33 additions and 21 deletions

View file

@ -1,3 +1,18 @@
2003-05-01 Paolo Carlini <pcarlini@unitus.it>
* include/bits/streambuf.tcc (basic_streambuf::xsgetn):
Const-ify some variables.
(basic_streambuf::xsputn): Likewise; change the type of some
variables to size_t.
(__copy_streambufs): Change some variables to size_t.
2003-05-01 Paolo Carlini <pcarlini@unitus.it>
* include/std/std_sstream.h (str()): Avoid constructing
a basic_string temporary not only when it would turn out
to be zero-sized but also when identical to the current
_M_string buffer.
2003-05-01 Paolo Carlini <pcarlini@unitus.it> 2003-05-01 Paolo Carlini <pcarlini@unitus.it>
* include/ext/stdio_filebuf.h * include/ext/stdio_filebuf.h

View file

@ -114,11 +114,11 @@ namespace std
streamsize __ret = 0; streamsize __ret = 0;
while (__ret < __n) while (__ret < __n)
{ {
size_t __buf_len = _M_in_end - _M_in_cur; const size_t __buf_len = _M_in_end - _M_in_cur;
if (__buf_len > 0) if (__buf_len > 0)
{ {
size_t __remaining = __n - __ret; const size_t __remaining = __n - __ret;
size_t __len = std::min(__buf_len, __remaining); const size_t __len = std::min(__buf_len, __remaining);
traits_type::copy(__s, _M_in_cur, __len); traits_type::copy(__s, _M_in_cur, __len);
__ret += __len; __ret += __len;
__s += __len; __s += __len;
@ -127,7 +127,7 @@ namespace std
if (__ret < __n) if (__ret < __n)
{ {
int_type __c = this->uflow(); const int_type __c = this->uflow();
if (!traits_type::eq_int_type(__c, traits_type::eof())) if (!traits_type::eq_int_type(__c, traits_type::eof()))
{ {
traits_type::assign(*__s++, traits_type::to_char_type(__c)); traits_type::assign(*__s++, traits_type::to_char_type(__c));
@ -148,11 +148,11 @@ namespace std
streamsize __ret = 0; streamsize __ret = 0;
while (__ret < __n) while (__ret < __n)
{ {
off_type __buf_len = _M_out_end - _M_out_cur; const size_t __buf_len = _M_out_end - _M_out_cur;
if (__buf_len > 0) if (__buf_len > 0)
{ {
off_type __remaining = __n - __ret; const size_t __remaining = __n - __ret;
off_type __len = std::min(__buf_len, __remaining); const size_t __len = std::min(__buf_len, __remaining);
traits_type::copy(_M_out_cur, __s, __len); traits_type::copy(_M_out_cur, __s, __len);
__ret += __len; __ret += __len;
__s += __len; __s += __len;
@ -161,7 +161,7 @@ namespace std
if (__ret < __n) if (__ret < __n)
{ {
int_type __c = this->overflow(traits_type::to_int_type(*__s)); const int_type __c = this->overflow(traits_type::to_int_type(*__s));
if (!traits_type::eq_int_type(__c, traits_type::eof())) if (!traits_type::eq_int_type(__c, traits_type::eof()))
{ {
++__ret; ++__ret;
@ -185,7 +185,6 @@ namespace std
basic_streambuf<_CharT, _Traits>* __sbout) basic_streambuf<_CharT, _Traits>* __sbout)
{ {
typedef typename _Traits::int_type int_type; typedef typename _Traits::int_type int_type;
typedef typename _Traits::off_type off_type;
streamsize __ret = 0; streamsize __ret = 0;
try try
@ -193,7 +192,7 @@ namespace std
for (;;) for (;;)
{ {
streamsize __xtrct; streamsize __xtrct;
const off_type __avail = __sbin->_M_in_end const size_t __avail = __sbin->_M_in_end
- __sbin->_M_in_cur; - __sbin->_M_in_cur;
if (__avail) if (__avail)
{ {
@ -206,7 +205,7 @@ namespace std
else else
{ {
streamsize __charsread; streamsize __charsread;
const off_type __size = __sbout->_M_out_end const size_t __size = __sbout->_M_out_end
- __sbout->_M_out_cur; - __sbout->_M_out_cur;
if (__size) if (__size)
{ {

View file

@ -140,14 +140,12 @@ namespace std
// represents the size of the initial string used to // represents the size of the initial string used to
// created the buffer, and may not be the correct size of // created the buffer, and may not be the correct size of
// the current stringbuf internal buffer. // the current stringbuf internal buffer.
__size_type __len = _M_string.size(); const __size_type __len = _M_string.size();
__size_type __nlen = this->_M_out_lim - this->_M_out_beg; const __size_type __nlen = this->_M_out_lim
if (__nlen) - this->_M_out_beg;
{ if (__nlen > __len)
__len = std::max(__nlen, __len);
__ret = __string_type(this->_M_out_beg, __ret = __string_type(this->_M_out_beg,
this->_M_out_beg + __len); this->_M_out_beg + __nlen);
}
} }
return __ret; return __ret;
} }