PR libstdc++/15002 (continued again)
2004-04-25 Paolo Carlini <pcarlini@suse.de> PR libstdc++/15002 (continued again) * include/bits/istream.tcc (getline(basic_istream<>&, basic_string<>&, _CharT)): Use a temporary buffer, thus avoiding reallocation for common case. * include/bits/basic_string.tcc (_S_construct(_InIterator, _InIterator, const _Alloc&, input_iterator_tag)): Tweak size of temporary buffer to a power of two. * testsuite/27_io/basic_istream/getline/char/4.cc: Add comment. From-SVN: r81163
This commit is contained in:
parent
c26fa757dc
commit
247791f5d1
@ -1,3 +1,16 @@
|
||||
2004-04-25 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
PR libstdc++/15002 (continued again)
|
||||
* include/bits/istream.tcc (getline(basic_istream<>&,
|
||||
basic_string<>&, _CharT)): Use a temporary buffer, thus
|
||||
avoiding reallocation for common case.
|
||||
|
||||
* include/bits/basic_string.tcc (_S_construct(_InIterator,
|
||||
_InIterator, const _Alloc&, input_iterator_tag)): Tweak size
|
||||
of temporary buffer to a power of two.
|
||||
|
||||
* testsuite/27_io/basic_istream/getline/char/4.cc: Add comment.
|
||||
|
||||
2004-04-25 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* testsuite/21_strings/basic_string/inserters_extractors/char/10.cc:
|
||||
|
@ -91,7 +91,7 @@ namespace std
|
||||
if (__beg == __end && __a == _Alloc())
|
||||
return _S_empty_rep()._M_refdata();
|
||||
// Avoid reallocation for common case.
|
||||
_CharT __buf[100];
|
||||
_CharT __buf[128];
|
||||
size_type __len = 0;
|
||||
while (__beg != __end && __len < sizeof(__buf) / sizeof(_CharT))
|
||||
{
|
||||
|
@ -1102,7 +1102,10 @@ namespace std
|
||||
{
|
||||
try
|
||||
{
|
||||
// Avoid reallocation for common case.
|
||||
__str.erase();
|
||||
_CharT __buf[128];
|
||||
__size_type __len = 0;
|
||||
const __int_type __idelim = _Traits::to_int_type(__delim);
|
||||
const __int_type __eof = _Traits::eof();
|
||||
__streambuf_type* __sb = __in.rdbuf();
|
||||
@ -1112,10 +1115,17 @@ namespace std
|
||||
&& !_Traits::eq_int_type(__c, __eof)
|
||||
&& !_Traits::eq_int_type(__c, __idelim))
|
||||
{
|
||||
__str += _Traits::to_char_type(__c);
|
||||
__c = __sb->snextc();
|
||||
if (__len == sizeof(__buf) / sizeof(_CharT))
|
||||
{
|
||||
__str.append(__buf, sizeof(__buf) / sizeof(_CharT));
|
||||
__len = 0;
|
||||
}
|
||||
__buf[__len++] = _Traits::to_char_type(__c);
|
||||
++__extracted;
|
||||
__c = __sb->snextc();
|
||||
}
|
||||
__str.append(__buf, __len);
|
||||
|
||||
if (_Traits::eq_int_type(__c, __eof))
|
||||
__err |= ios_base::eofbit;
|
||||
else if (_Traits::eq_int_type(__c, __idelim))
|
||||
|
@ -25,6 +25,8 @@
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
// 27.6.1.3 unformatted input functions
|
||||
|
||||
#include <cstring> // for strlen
|
||||
#include <istream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
Loading…
Reference in New Issue
Block a user