+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:
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))
{
{
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();
&& !_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))
// 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>