[Patch] Fix libstdc++/9424

Paolo Carlini pcarlini@unitus.it
Thu Feb 27 19:09:00 GMT 2003


Hi,

this is a fix along the lines suggested by Pétur: sgetn is
used only when a next sputn cannot possibly fail since the
corresponding _M_out_buf_size() is sufficiently large.
Otherwise, we fall back to an always correct
one-char-at-a-time loop.

Note that, in fact, in the former "fast" case, there is
an overhead due to the __builtin_alloca call which is not
present in the latter: it may be well possible that the
latter loop it's actually faster than the former
__builtin_alloca-sgetn-sputn sequence, when, say, less than
~10 chars have to be copied, and the condition could be
profitably changed from:

    if (__size > 1)

to, say

    if (__size > 10)

That's why I have not special cased the loop to a series of
a few (ugly) 'if' which would be in fact equivalent to it
when 'if (__size > 1)' is the condition.

Therefore, I plan to conduct some benchmarks...

Shall we commit the fix to the trunk? (tested x86-linux)

Paolo.

////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_9424
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030227/0752c05c/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_9424
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030227/0752c05c/attachment-0001.ksh>


More information about the Libstdc++ mailing list