diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-25 15:16:49 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-25 15:16:49 +0000 |
commit | d7de596fde9ea1e201d1d49228708587e27f6fbb (patch) | |
tree | aa6a327e1de2d3dcc3e3de76651e41357abf8fbb | |
parent | 4b592242c998f8b5ed827945c0d504cd7e88bd18 (diff) | |
download | ppe42-gcc-d7de596fde9ea1e201d1d49228708587e27f6fbb.tar.gz ppe42-gcc-d7de596fde9ea1e201d1d49228708587e27f6fbb.zip |
2004-10-25 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_Rep::_M_is_safe): Move to
basic_string as _M_disjunct, adjust to take only __s.
* include/bits/basic_string.tcc: Adjust consistently callers.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89534 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.h | 16 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.tcc | 8 |
3 files changed, 18 insertions, 12 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 51f39320ebd..74f87faf2d1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,4 +1,10 @@ 2004-10-25 Paolo Carlini <pcarlini@suse.de> + + * include/bits/basic_string.h (_Rep::_M_is_safe): Move to + basic_string as _M_disjunct, adjust to take only __s. + * include/bits/basic_string.tcc: Adjust consistently callers. + +2004-10-25 Paolo Carlini <pcarlini@suse.de> * include/bits/basic_string.tcc (assign(const _CharT*, size_type)): Adjust bit missing from the previous commit. diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 9900798339a..817123365cc 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -185,14 +185,6 @@ namespace std _M_is_shared() const { return this->_M_refcount > 0; } - // True if source and destination do not overlap. - bool - _M_is_safe(const _CharT* __data, const _CharT* __s) const - { - return (less<const _CharT*>()(__s, __data) - || less<const _CharT*>()(__data + this->_M_length, __s)); - } - void _M_set_leaked() { this->_M_refcount = -1; } @@ -325,6 +317,14 @@ namespace std return __testoff ? __off : this->size() - __pos; } + // True if _Rep and source do not overlap. + bool + _M_disjunct(const _CharT* __s) const + { + return (less<const _CharT*>()(__s, _M_data()) + || less<const _CharT*>()(_M_data() + this->size(), __s)); + } + // When __n = 1 way faster than the general multichar // traits_type::copy/move/assign. static void diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 51fe9f55472..9e59e2c6b50 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -246,7 +246,7 @@ namespace std { __glibcxx_requires_string_len(__s, __n); _M_check_length(this->size(), __n, "basic_string::assign"); - if (_M_rep()->_M_is_safe(_M_data(), __s) || _M_rep()->_M_is_shared()) + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) return _M_replace_safe(size_type(0), this->size(), __s, __n); else { @@ -273,7 +273,7 @@ namespace std const size_type __len = __n + this->size(); if (__len > this->capacity() || _M_rep()->_M_is_shared()) { - if (_M_rep()->_M_is_safe(_M_data(), __s)) + if (_M_disjunct(__s)) this->reserve(__len); else { @@ -314,7 +314,7 @@ namespace std __glibcxx_requires_string_len(__s, __n); _M_check(__pos, "basic_string::insert"); _M_check_length(size_type(0), __n, "basic_string::insert"); - if (_M_rep()->_M_is_safe(_M_data(), __s) || _M_rep()->_M_is_shared()) + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) return _M_replace_safe(__pos, size_type(0), __s, __n); else { @@ -348,7 +348,7 @@ namespace std __n1 = _M_limit(__pos, __n1); _M_check_length(__n1, __n2, "basic_string::replace"); bool __left; - if (_M_rep()->_M_is_safe(_M_data(), __s) || _M_rep()->_M_is_shared()) + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) return _M_replace_safe(__pos, __n1, __s, __n2); else if ((__left = __s + __n2 <= _M_data() + __pos) || _M_data() + __pos + __n1 <= __s) |