This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/44510] stream unformatted inserter is slower than formatted inserter



------- Comment #1 from paolo dot carlini at oracle dot com  2010-06-13 12:12 -------
First, note that the *extractor*, ie, read, is slower, not the inserter. That
said, I think it's not at all obvious that read must be faster than the pointer
extractor, because in the latter case the parsing itself is a bit slower but
then the result can be copied 8 bytes at once as a builtin pointer type.
Barring quite sophisticated compiler optimizations, in general this is not the
case for read. In fact, other completely unrelated implementations of the
runtime library, eg in SunStudio, also have the formatted case faster than the
unformatted, for this example. That said, I think we have some potential margin
of improvement with a patch like the one I'm attaching below. Please try it out
and let me know how it goes (in case some tweaks will be also needed to the
exports, minor issues):

Index: sstream
===================================================================
--- sstream     (revision 160663)
+++ sstream     (working copy)
@@ -219,6 +219,13 @@
       seekpos(pos_type __sp,
              ios_base::openmode __mode = ios_base::in | ios_base::out);

+      virtual streamsize
+      xsgetn(char_type* __s, streamsize __n)
+      {
+       _M_update_egptr();
+       return __streambuf_type::xsgetn(__s, __n);
+      }
+
       // Internal function for correctly updating the internal buffer
       // for a particular _M_string, due to initialization or re-sizing
       // of an existing _M_string.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-06-13 12:12:57
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44510


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]