This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: streambuf performance 200x


On Thu, Feb 13, 2003 at 11:11:13AM -0700, Martin Sebor wrote:
> Nathan Myers wrote:
> >It's time to talk about fixing core streambuf performance.
> 
> Note that this is complicated by the requirements on strstreambuf.
> This program must still return 0 (it currently fails with a non-0
> exit status with libstdc++):
> 
>     #include <cstring>
>     #include <strstream>
> 
>     int main ()
>     {
>         char buf[] = "abc";
>         std::strstreambuf sb (buf, sizeof buf, buf);
>         sb.freeze ();
>         sb.sputc ('x');
>         return std::strcmp (buf, "abc");
>     }

By my reading, this constructs a strstreambuf with setg(buf, buf, buf)
and setp(buf, buf+4), and strmode == 0.  (An attempt to read would 
result in a call to underflow, which would return EOF.)  The call to 
freeze() has no effect, because it only operates on dynamic bufs.  
The sputc() puts an 'x' at *buf, and the strcmp returns 1.

Where am I mistaken?  Alternatively, what did you mean to say?

Nathan Myers
ncm@cantrip.org


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