This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[RFC/patch] Fixing libstdc++/11378 and, while at it... ;)
- From: Jerry Quinn <jlquinn at optonline dot net>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: libstdc++ at gcc dot gnu dot org, Nathan Myers <ncm-nospam at cantrip dot org>
- Date: Wed, 02 Jul 2003 08:39:26 -0400
- Subject: [RFC/patch] Fixing libstdc++/11378 and, while at it... ;)
- References: <3F024BD9.7020405@unitus.it>
Paolo Carlini writes:
> Hi,
[nice performance improvements deleted]
>
> Comments appreciated!
>
> Paolo.
>
> ////////////
> diff -urN libstdc++-v3-curr/include/std/std_fstream.h libstdc++-v3/include/std/std_fstream.h
> --- libstdc++-v3-curr/include/std/std_fstream.h 2003-06-30 13:17:22.000000000 +0200
> +++ libstdc++-v3/include/std/std_fstream.h 2003-07-02 04:32:49.000000000 +0200
> @@ -399,8 +399,14 @@
> virtual streamsize
> xsputn(const char_type* __s, streamsize __n)
> {
> - _M_destroy_pback();
> - return __streambuf_type::xsputn(__s, __n);
> + streamsize __ret = 0;
> + const bool __testout = this->_M_mode & ios_base::out;
> + if(__testout && !_M_reading && this->_M_buf_size == 1
Should this be _M_buf_size >= 1?
> + && __check_facet(_M_codecvt).always_noconv())
always_noconv() is another virtual. The answer to this could be
cached in a bool. That will avoid the __check_facet test and the
virtual call.
> + __ret = _M_file.xsputn(reinterpret_cast<const char*>(__s), __n);
> + else
> + __ret = __streambuf_type::xsputn(__s, __n);
> + return __ret;
Cool! I started to look a bit at this since it also shows up in the
hot path for the integer output benchmark, but hadn't gotten very far.
Jerry