diff options
| author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-02 00:14:49 +0000 |
|---|---|---|
| committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-02 00:14:49 +0000 |
| commit | b1aadeefff88b59331250c791219462af6c43a54 (patch) | |
| tree | 587ab455dc5c8464dd95e9b8a0d8249079ed690b | |
| parent | 2304077f8c17e76fec6e63f13f9009b95add53be (diff) | |
| download | ppe42-gcc-b1aadeefff88b59331250c791219462af6c43a54.tar.gz ppe42-gcc-b1aadeefff88b59331250c791219462af6c43a54.zip | |
2003-05-01 Paolo Carlini <pcarlini@unitus.it>
* include/bits/sstream.tcc (overflow): Instead of calling
str(), then _M_string.reserve, thus copying the contents
of the current buffer two times, just copy the latter in
a temporary, then use the 'swap trick'.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66358 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
| -rw-r--r-- | libstdc++-v3/include/bits/sstream.tcc | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index cd55a6b5e01..60d51375596 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2003-05-01 Paolo Carlini <pcarlini@unitus.it> + * include/bits/sstream.tcc (overflow): Instead of calling + str(), then _M_string.reserve, thus copying the contents + of the current buffer two times, just copy the latter in + a temporary, then use the 'swap trick'. + +2003-05-01 Paolo Carlini <pcarlini@unitus.it> + * include/std/std_sstream.h (str()): Revert the best of the previous 'improvement', incorrect due to the COW nature of v3 basic_string; simplify. diff --git a/libstdc++-v3/include/bits/sstream.tcc b/libstdc++-v3/include/bits/sstream.tcc index 11751783722..c09553127cc 100644 --- a/libstdc++-v3/include/bits/sstream.tcc +++ b/libstdc++-v3/include/bits/sstream.tcc @@ -100,11 +100,15 @@ namespace std // Order these tests done in is unspecified by the standard. if (!__testput) { - // Force-allocate, re-sync. - _M_string = this->str(); // In virtue of DR 169 (TC) we are allowed to grow more than // one char. That's easy to implement thanks to the exponential // growth policy builtin into basic_string. + __string_type __tmp; + __tmp.reserve(__len); + __tmp.assign(_M_string.data(), + this->_M_out_end - this->_M_out_beg); + _M_string.swap(__tmp); + // Just to be sure... _M_string.reserve(__len); _M_really_sync(const_cast<char_type*>(_M_string.data()), this->_M_in_cur - this->_M_in_beg, |

