2004-01-24 Paolo Carlini <pcarlini@suse.de>
+ * include/bits/basic_string.tcc (rfind(_CharT, size_type)):
+ Revert last change to use std::min: machine language is worse.
+ (find_last_of(const _CharT*, size_type, size_type)): Ditto.
+ (find_last_not_of(const _CharT*, size_type, size_type)): Ditto.
+ (find_last_not_of(_CharT, size_type)): Ditto.
+
+ * include/bits/basic_string.tcc (insert(size_type, const _CharT*,
+ size_type)): Discard the value returned by _M_check.
+ (replace(size_type, size_type, const _CharT*, size_type)): Ditto.
+ (append(const basic_string&, size_type, size_type)): Ditto.
+ (copy(_CharT*, size_type, size_type)): Ditto.
+ (compare(size_type, size_type, const basic_string&)): Ditto.
+ (compare(size_type, size_type, const basic_string&,
+ size_type, size_type)): Ditto.
+ (compare(size_type, size_type, const _CharT*)): Ditto.
+ (compare(size_type, size_type, const _CharT*, size_type)): Ditto.
+
+2004-01-24 Paolo Carlini <pcarlini@suse.de>
+
* include/bits/basic_string.h (insert(size_type,
const basic_string&, size_type, size_type)): Define inline here.
* include/bits/basic_string.tcc (insert(size_type,
insert(size_type __pos, const _CharT* __s, size_type __n)
{
__glibcxx_requires_string_len(__s, __n);
- __pos = _M_check(__pos, "basic_string::insert");
+ _M_check(__pos, "basic_string::insert");
if (this->max_size() - this->size() < __n)
__throw_length_error("basic_string::insert");
if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
size_type __n2)
{
__glibcxx_requires_string_len(__s, __n2);
- __pos = _M_check(__pos, "basic_string::replace");
+ _M_check(__pos, "basic_string::replace");
__n1 = _M_limit(__pos, __n1);
if (this->max_size() - (this->size() - __n1) < __n2)
__throw_length_error("basic_string::replace");
// Iff appending itself, string needs to pre-reserve the
// correct size so that _M_mutate does not clobber the
// pointer __str._M_data() formed here.
- __pos = __str._M_check(__pos, "basic_string::append");
+ __str._M_check(__pos, "basic_string::append");
__n = __str._M_limit(__pos, __n);
const size_type __len = __n + this->size();
if (__len > this->capacity())
basic_string<_CharT, _Traits, _Alloc>::
copy(_CharT* __s, size_type __n, size_type __pos) const
{
- __pos = _M_check(__pos, "basic_string::copy");
+ _M_check(__pos, "basic_string::copy");
__n = _M_limit(__pos, __n);
__glibcxx_requires_string_len(__s, __n);
if (__n)
basic_string<_CharT, _Traits, _Alloc>::
rfind(_CharT __c, size_type __pos) const
{
- const size_type __size = this->size();
+ size_type __size = this->size();
if (__size)
{
- __pos = std::min(size_type(__size - 1), __pos);
- for (++__pos; __pos-- > 0; )
- if (traits_type::eq(_M_data()[__pos], __c))
- return __pos;
+ if (--__size > __pos)
+ __size = __pos;
+ for (++__size; __size-- > 0; )
+ if (traits_type::eq(_M_data()[__size], __c))
+ return __size;
}
return npos;
}
find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{
__glibcxx_requires_string_len(__s, __n);
- const size_type __size = this->size();
+ size_type __size = this->size();
if (__size)
- {
- __pos = std::min(size_type(__size - 1), __pos);
- do
+ {
+ if (--__size > __pos)
+ __size = __pos;
+ do
{
- if (!traits_type::find(__s, __n, _M_data()[__pos]))
- return __pos;
+ if (!traits_type::find(__s, __n, _M_data()[__size]))
+ return __size;
}
- while (__pos--);
+ while (__size--);
}
return npos;
}
basic_string<_CharT, _Traits, _Alloc>::
find_last_not_of(_CharT __c, size_type __pos) const
{
- const size_type __size = this->size();
+ size_type __size = this->size();
if (__size)
{
- __pos = std::min(size_type(__size - 1), __pos);
+ if (--__size > __pos)
+ __size = __pos;
do
{
- if (!traits_type::eq(_M_data()[__pos], __c))
- return __pos;
+ if (!traits_type::eq(_M_data()[__size], __c))
+ return __size;
}
- while (__pos--);
+ while (__size--);
}
return npos;
}
basic_string<_CharT, _Traits, _Alloc>::
compare(size_type __pos, size_type __n, const basic_string& __str) const
{
- __pos = _M_check(__pos, "basic_string::compare");
+ _M_check(__pos, "basic_string::compare");
__n = _M_limit(__pos, __n);
const size_type __osize = __str.size();
const size_type __len = std::min(__n, __osize);
compare(size_type __pos1, size_type __n1, const basic_string& __str,
size_type __pos2, size_type __n2) const
{
- __pos1 = _M_check(__pos1, "basic_string::compare");
- __pos2 = __str._M_check(__pos2, "basic_string::compare");
+ _M_check(__pos1, "basic_string::compare");
+ __str._M_check(__pos2, "basic_string::compare");
__n1 = _M_limit(__pos1, __n1);
__n2 = __str._M_limit(__pos2, __n2);
const size_type __len = std::min(__n1, __n2);
compare(size_type __pos, size_type __n1, const _CharT* __s) const
{
__glibcxx_requires_string(__s);
- __pos = _M_check(__pos, "basic_string::compare");
+ _M_check(__pos, "basic_string::compare");
__n1 = _M_limit(__pos, __n1);
const size_type __osize = traits_type::length(__s);
const size_type __len = std::min(__n1, __osize);
size_type __n2) const
{
__glibcxx_requires_string_len(__s, __n2);
- __pos = _M_check(__pos, "basic_string::compare");
+ _M_check(__pos, "basic_string::compare");
__n1 = _M_limit(__pos, __n1);
const size_type __len = std::min(__n1, __n2);
int __r = traits_type::compare(_M_data() + __pos, __s, __len);