Commit d1768069 by Nathan Myers Committed by Paolo Carlini

fstream.tcc (xsgetn): Slightly tweak the recent fix for 11722...

2004-09-14  Nathan Myers  <ncm@cantrip.org>

	* include/bits/fstream.tcc (xsgetn): Slightly tweak the recent fix
	for 11722: copy can replace move; the common case is __avail == 0.

From-SVN: r87501
parent 3b53cddc
2004-09-14 Nathan Myers <ncm@cantrip.org>
* include/bits/fstream.tcc (xsgetn): Slightly tweak the recent fix
for 11722: copy can replace move; the common case is __avail == 0.
2004-09-14 Paolo Carlini <pcarlini@suse.de> 2004-09-14 Paolo Carlini <pcarlini@suse.de>
* include/bits/cpp_type_traits.h: Rename __is_trivially_copyable * include/bits/cpp_type_traits.h: Rename __is_trivially_copyable
......
...@@ -524,14 +524,17 @@ namespace std ...@@ -524,14 +524,17 @@ namespace std
{ {
// First, copy the chars already present in the buffer. // First, copy the chars already present in the buffer.
const streamsize __avail = this->egptr() - this->gptr(); const streamsize __avail = this->egptr() - this->gptr();
if (__avail == 1) if (__avail != 0)
*__s = *this->gptr(); {
else if (__avail > 1) if (__avail == 1)
traits_type::move(__s, this->gptr(), __avail); *__s = *this->gptr();
__s += __avail; else if (__avail > 1)
this->gbump(__avail); traits_type::copy(__s, this->gptr(), __avail);
__ret += __avail; __s += __avail;
__n -= __avail; this->gbump(__avail);
__ret += __avail;
__n -= __avail;
}
const streamsize __len = _M_file.xsgetn(reinterpret_cast<char*>(__s), const streamsize __len = _M_file.xsgetn(reinterpret_cast<char*>(__s),
__n); __n);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment