fstream.tcc (xsgetn): Slightly tweak the recent fix for 11722...
authorNathan Myers <ncm@cantrip.org>
Tue, 14 Sep 2004 19:11:46 +0000 (19:11 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 14 Sep 2004 19:11:46 +0000 (19:11 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc

index 79919512177169de271c792e2d7931b633936d78..8b52da2c9e4ff482918103d8ffb6e0c3e47d1cd2 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * include/bits/cpp_type_traits.h: Rename __is_trivially_copyable
index 542dc6e8bc4ff3ee86220725dca514c9eddf3486..c24d4cac49fc3b17e1237835a434214d12f4bb37 100644 (file)
@@ -524,14 +524,17 @@ namespace std
         {
           // First, copy the chars already present in the buffer.
           const streamsize __avail = this->egptr() - this->gptr();
-          if (__avail == 1)
-            *__s = *this->gptr();
-          else if (__avail > 1)
-            traits_type::move(__s, this->gptr(), __avail);
-          __s += __avail;
-          this->gbump(__avail);
-          __ret += __avail;
-          __n -= __avail;
+          if (__avail != 0)
+            {
+              if (__avail == 1)
+                *__s = *this->gptr();
+              else if (__avail > 1)
+                traits_type::copy(__s, this->gptr(), __avail);
+              __s += __avail;
+              this->gbump(__avail);
+              __ret += __avail;
+              __n -= __avail;
+            }
 
           const streamsize __len = _M_file.xsgetn(reinterpret_cast<char*>(__s),
                                                   __n);