[patch] PR 8761 and 7076, take 2

Nathan Myers ncm-nospam@cantrip.org
Thu Jan 16 16:16:00 GMT 2003


On Thu, Jan 16, 2003 at 01:08:53AM -0500, Jerry Quinn wrote:
> 
> Here's the revised I/O patch including the changes I used from Benjamin's
> reorg.  In addition, I've dispensed with using _S_format_int() and
> ctype.widen().  Also, I'm no longer using __convert_from_v().  There's a 
> new function __convert_from_int() with a better interface.  And finally,
> I've made _M_insert use the underlying sputn() routine for the streambuf.

This is great work.  
 
> All told, this patch brings execution time of PR8761's testcase from 25
> seconds to 7.9 seconds.  At this point, I think the low-hanging fruit is
> mostly gone.

We shall see about that. :-)

> There is an annoying wart where I had to make a friend declaration inside
> ostreambuf_iterator to get access to the underlying streambuf.  Suggestions
> for a cleaner implementation are quite welcome.

There's _nothing_ wrong with making friends within the library.
Which is a friend of what may change freely without breaking the ABI.
It's only inconvenient when the list of friends gets too long.

You might prefer to make a public, non-standard member (e.g. __sbuf())
of ostreambuf_iterator to give access to the streambuf.  Probably the 
standard should have specified one.  (Mea culpa.)

> Another ugliness is that I had to force the cache to be called and
> built from basic_ios::imbue.  The problem was that in the previous
> patch, the cache wasn't created until an ostream insertion was done.
> If you imbued the stream with a modified locale, the imbue event would
> not get to the cache because it didn't exist yet.  Then, the cache for
> char and wchar_t would be created during the inserter.  These variants
> are always considered valid, so the caches wouldn't be updated with
> the new locale info.

I don't see anything wrong with moving work into imbue.  Nobody imbues
a locale without doing I/O afterward.

Nathan Myers
ncm-nospam@cantrip.org



More information about the Libstdc++ mailing list