[Patch] Tiny (but cool ;) change to bitset::_M_copy_from_string

Paolo Carlini pcarlini@suse.de
Thu Jan 26 18:02:00 GMT 2006


Hi,

today, prompted by Zdenek loop reversal patch, was re-checking that the
recent (by hand) loop reversal in bitset was not worsening the code
(indeed, everything is fine, even slightly better than 4_1) and noticed
this funny thing: in _M_copy_from_string (inconsistently with
_M_copy_to_string) we are calling the general bitset::set(size_t, bool),
instead of the internal, unchecked, _Unchecked_set.

That means two completely redundant conditionals (one for out of range;
one for set vs reset basing on the second argument) and, for this stupid
snippet, for example:

  string s(10000, '1');
  for (unsigned i = 0; i < 100000; ++i)
    bitset<10000> bs(s);

On an x86-linux, P4-2400, -O2:

Current mainline
----------------
4.696u 0.004s 0:04.69 100.0%    0+0k 0+0io 0pf+0w

Current mainline + patch
------------------------
3.848u 0.000s 0:03.84 100.0%    0+0k 0+0io 0pf+0w


Too cool? ;) Seriously, I cannot imagine anything wrong with the change,
but please have a close look...

Tested x86-linux.

Paolo.

///////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_bitset
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20060126/d5524135/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_bitset
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20060126/d5524135/attachment-0001.ksh>


More information about the Libstdc++ mailing list