sso_string_base.h: Minor formatting and stylistic fixes.

2005-11-21  Paolo Carlini  <pcarlini@suse.de>

	* include/ext/sso_string_base.h: Minor formatting and stylistic fixes.
	(__sso_string_base<>::_M_get_allocator): Return by const ref.
	* include/ext/rc_string_base.h: Likewise.
	(__rc_string_base<>::_M_get_allocator): Return by const ref.
	(__rc_string_base<>::_M_dispose): Take void, use _M_get_allocator.
	(__rc_string_base<>::_M_grab): Take one alloc, use _M_get_allocator.
	(__rc_string_base<>::~__rc_string_base,
	__rc_string_base(const __rc_string_base&), _M_assign, _M_reserve,
	_M_mutate): Adjust.
	* include/ext/vstring_util.h: Minor stylistic fixes.

From-SVN: r107317
This commit is contained in:
Paolo Carlini 2005-11-21 18:38:05 +00:00 committed by Paolo Carlini
parent e20dcbefa5
commit b6cb8dc2d8
4 changed files with 46 additions and 38 deletions

View file

@ -1,3 +1,16 @@
2005-11-21 Paolo Carlini <pcarlini@suse.de>
* include/ext/sso_string_base.h: Minor formatting and stylistic fixes.
(__sso_string_base<>::_M_get_allocator): Return by const ref.
* include/ext/rc_string_base.h: Likewise.
(__rc_string_base<>::_M_get_allocator): Return by const ref.
(__rc_string_base<>::_M_dispose): Take void, use _M_get_allocator.
(__rc_string_base<>::_M_grab): Take one alloc, use _M_get_allocator.
(__rc_string_base<>::~__rc_string_base,
__rc_string_base(const __rc_string_base&), _M_assign, _M_reserve,
_M_mutate): Adjust.
* include/ext/vstring_util.h: Minor stylistic fixes.
2005-11-18 Paolo Carlini <pcarlini@suse.de>
* include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the

View file

@ -193,17 +193,17 @@ namespace __gnu_cxx
{ return &((reinterpret_cast<_Rep*>(_M_data()))[-1]); }
_CharT*
_M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2) const
_M_grab(const _Alloc& __alloc) const
{
return (!_M_is_leaked() && __alloc1 == __alloc2)
? _M_rep()->_M_refcopy() : _M_rep()->_M_clone(__alloc1);
return (!_M_is_leaked() && _M_get_allocator() == __alloc)
? _M_rep()->_M_refcopy() : _M_rep()->_M_clone(__alloc);
}
void
_M_dispose(const _Alloc& __a)
_M_dispose()
{
if (__exchange_and_add(&_M_rep()->_M_info._M_refcount, -1) <= 0)
_M_rep()->_M_destroy(__a);
_M_rep()->_M_destroy(_M_get_allocator());
} // XXX MT
bool
@ -219,7 +219,7 @@ namespace __gnu_cxx
// _S_construct_aux is used to implement the 21.3.1 para 15 which
// requires special behaviour if _InIterator is an integral type
template<class _InIterator>
template<typename _InIterator>
static _CharT*
_S_construct_aux(_InIterator __beg, _InIterator __end,
const _Alloc& __a, __false_type)
@ -228,14 +228,14 @@ namespace __gnu_cxx
return _S_construct(__beg, __end, __a, _Tag());
}
template<class _InIterator>
template<typename _InIterator>
static _CharT*
_S_construct_aux(_InIterator __beg, _InIterator __end,
const _Alloc& __a, __true_type)
{ return _S_construct(static_cast<size_type>(__beg),
static_cast<value_type>(__end), __a); }
template<class _InIterator>
template<typename _InIterator>
static _CharT*
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
{
@ -244,14 +244,14 @@ namespace __gnu_cxx
}
// For Input Iterators, used in istreambuf_iterators, etc.
template<class _InIterator>
template<typename _InIterator>
static _CharT*
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
std::input_iterator_tag);
// For forward_iterators up to random_access_iterators, used for
// string::iterator, _CharT*, etc.
template<class _FwdIterator>
template<typename _FwdIterator>
static _CharT*
_S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
std::forward_iterator_tag);
@ -309,9 +309,9 @@ namespace __gnu_cxx
const _Alloc& __a);
~__rc_string_base()
{ _M_dispose(_M_get_allocator()); }
{ _M_dispose(); }
allocator_type
const allocator_type&
_M_get_allocator() const
{ return _M_dataplus; }
@ -372,9 +372,6 @@ namespace __gnu_cxx
// The below implements an exponential growth policy, necessary to
// meet amortized linear time requirements of the library: see
// http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html.
// It's active for allocations requiring an amount of memory above
// system pagesize. This is consistent with the requirements of the
// standard: http://gcc.gnu.org/ml/libstdc++/2001-07/msg00130.html
if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
__capacity = 2 * __old_capacity;
@ -441,8 +438,7 @@ namespace __gnu_cxx
__rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(const __rc_string_base& __rcs)
: _M_dataplus(__rcs._M_get_allocator(),
__rcs._M_grab(_Alloc(__rcs._M_get_allocator()),
__rcs._M_get_allocator())) { }
__rcs._M_grab(__rcs._M_get_allocator())) { }
template<typename _CharT, typename _Traits, typename _Alloc>
__rc_string_base<_CharT, _Traits, _Alloc>::
@ -516,7 +512,7 @@ namespace __gnu_cxx
}
template<typename _CharT, typename _Traits, typename _Alloc>
template <typename _InIterator>
template<typename _InIterator>
_CharT*
__rc_string_base<_CharT, _Traits, _Alloc>::
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
@ -587,9 +583,8 @@ namespace __gnu_cxx
{
if (_M_rep() != __rcs._M_rep())
{
const allocator_type __a = _M_get_allocator();
_CharT* __tmp = __rcs._M_grab(__a, __rcs._M_get_allocator());
_M_dispose(__a);
_CharT* __tmp = __rcs._M_grab(_M_get_allocator());
_M_dispose();
_M_data(__tmp);
}
}
@ -605,9 +600,9 @@ namespace __gnu_cxx
if (__res < _M_length())
__res = _M_length();
const allocator_type __a = _M_get_allocator();
_CharT* __tmp = _M_rep()->_M_clone(__a, __res - _M_length());
_M_dispose(__a);
_CharT* __tmp = _M_rep()->_M_clone(_M_get_allocator(),
__res - _M_length());
_M_dispose();
_M_data(__tmp);
}
}
@ -624,8 +619,8 @@ namespace __gnu_cxx
if (__new_size > _M_capacity() || _M_is_shared())
{
// Must reallocate.
const allocator_type __a = _M_get_allocator();
_Rep* __r = _Rep::_S_create(__new_size, _M_capacity(), __a);
_Rep* __r = _Rep::_S_create(__new_size, _M_capacity(),
_M_get_allocator());
if (__pos)
_S_copy(__r->_M_refdata(), _M_data(), __pos);
@ -633,7 +628,7 @@ namespace __gnu_cxx
_S_copy(__r->_M_refdata() + __pos + __len2,
_M_data() + __pos + __len1, __how_much);
_M_dispose(__a);
_M_dispose();
_M_data(__r->_M_refdata());
}
else if (__how_much && __len1 != __len2)

View file

@ -74,8 +74,8 @@ namespace __gnu_cxx
union
{
_CharT _M_local_data[_S_local_capacity + 1];
size_type _M_allocated_capacity;
_CharT _M_local_data[_S_local_capacity + 1];
size_type _M_allocated_capacity;
};
void
@ -99,7 +99,7 @@ namespace __gnu_cxx
_M_create(size_type&, size_type);
void
_M_dispose() throw()
_M_dispose()
{
if (!_M_is_local())
_M_destroy(_M_allocated_capacity + 1);
@ -110,7 +110,7 @@ namespace __gnu_cxx
// _M_construct_aux is used to implement the 21.3.1 para 15 which
// requires special behaviour if _InIterator is an integral type
template<class _InIterator>
template<typename _InIterator>
void
_M_construct_aux(_InIterator __beg, _InIterator __end, __false_type)
{
@ -118,13 +118,13 @@ namespace __gnu_cxx
_M_construct(__beg, __end, _Tag());
}
template<class _InIterator>
template<typename _InIterator>
void
_M_construct_aux(_InIterator __beg, _InIterator __end, __true_type)
{ _M_construct(static_cast<size_type>(__beg),
static_cast<value_type>(__end)); }
template<class _InIterator>
template<typename _InIterator>
void
_M_construct(_InIterator __beg, _InIterator __end)
{
@ -133,14 +133,14 @@ namespace __gnu_cxx
}
// For Input Iterators, used in istreambuf_iterators, etc.
template<class _InIterator>
template<typename _InIterator>
void
_M_construct(_InIterator __beg, _InIterator __end,
std::input_iterator_tag);
// For forward_iterators up to random_access_iterators, used for
// string::iterator, _CharT*, etc.
template<class _FwdIterator>
template<typename _FwdIterator>
void
_M_construct(_FwdIterator __beg, _FwdIterator __end,
std::forward_iterator_tag);
@ -202,7 +202,7 @@ namespace __gnu_cxx
~__sso_string_base()
{ _M_dispose(); }
allocator_type
const allocator_type&
_M_get_allocator() const
{ return _M_dataplus; }
@ -392,7 +392,7 @@ namespace __gnu_cxx
}
template<typename _CharT, typename _Traits, typename _Alloc>
template <typename _InIterator>
template<typename _InIterator>
void
__sso_string_base<_CharT, _Traits, _Alloc>::
_M_construct(_InIterator __beg, _InIterator __end,

View file

@ -160,7 +160,7 @@ namespace __gnu_cxx
// _S_copy_chars is a separate template to permit specialization
// to optimize for the common case of pointers as iterators.
template<class _Iterator>
template<typename _Iterator>
static void
_S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
{