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.
_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; }
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
{
__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
{
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
{
__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
{
__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)