Commit b6cb8dc2 by Paolo Carlini Committed by Paolo Carlini

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
parent e20dcbef
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> 2005-11-18 Paolo Carlini <pcarlini@suse.de>
* include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the * include/ext/rc_string_base.h (__rc_string_base<>::_Rep): Avoid the
......
...@@ -193,17 +193,17 @@ namespace __gnu_cxx ...@@ -193,17 +193,17 @@ namespace __gnu_cxx
{ return &((reinterpret_cast<_Rep*>(_M_data()))[-1]); } { return &((reinterpret_cast<_Rep*>(_M_data()))[-1]); }
_CharT* _CharT*
_M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2) const _M_grab(const _Alloc& __alloc) const
{ {
return (!_M_is_leaked() && __alloc1 == __alloc2) return (!_M_is_leaked() && _M_get_allocator() == __alloc)
? _M_rep()->_M_refcopy() : _M_rep()->_M_clone(__alloc1); ? _M_rep()->_M_refcopy() : _M_rep()->_M_clone(__alloc);
} }
void void
_M_dispose(const _Alloc& __a) _M_dispose()
{ {
if (__exchange_and_add(&_M_rep()->_M_info._M_refcount, -1) <= 0) 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 } // XXX MT
bool bool
...@@ -219,7 +219,7 @@ namespace __gnu_cxx ...@@ -219,7 +219,7 @@ namespace __gnu_cxx
// _S_construct_aux is used to implement the 21.3.1 para 15 which // _S_construct_aux is used to implement the 21.3.1 para 15 which
// requires special behaviour if _InIterator is an integral type // requires special behaviour if _InIterator is an integral type
template<class _InIterator> template<typename _InIterator>
static _CharT* static _CharT*
_S_construct_aux(_InIterator __beg, _InIterator __end, _S_construct_aux(_InIterator __beg, _InIterator __end,
const _Alloc& __a, __false_type) const _Alloc& __a, __false_type)
...@@ -228,14 +228,14 @@ namespace __gnu_cxx ...@@ -228,14 +228,14 @@ namespace __gnu_cxx
return _S_construct(__beg, __end, __a, _Tag()); return _S_construct(__beg, __end, __a, _Tag());
} }
template<class _InIterator> template<typename _InIterator>
static _CharT* static _CharT*
_S_construct_aux(_InIterator __beg, _InIterator __end, _S_construct_aux(_InIterator __beg, _InIterator __end,
const _Alloc& __a, __true_type) const _Alloc& __a, __true_type)
{ return _S_construct(static_cast<size_type>(__beg), { return _S_construct(static_cast<size_type>(__beg),
static_cast<value_type>(__end), __a); } static_cast<value_type>(__end), __a); }
template<class _InIterator> template<typename _InIterator>
static _CharT* static _CharT*
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a) _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a)
{ {
...@@ -244,14 +244,14 @@ namespace __gnu_cxx ...@@ -244,14 +244,14 @@ namespace __gnu_cxx
} }
// For Input Iterators, used in istreambuf_iterators, etc. // For Input Iterators, used in istreambuf_iterators, etc.
template<class _InIterator> template<typename _InIterator>
static _CharT* static _CharT*
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
std::input_iterator_tag); std::input_iterator_tag);
// For forward_iterators up to random_access_iterators, used for // For forward_iterators up to random_access_iterators, used for
// string::iterator, _CharT*, etc. // string::iterator, _CharT*, etc.
template<class _FwdIterator> template<typename _FwdIterator>
static _CharT* static _CharT*
_S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a, _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
std::forward_iterator_tag); std::forward_iterator_tag);
...@@ -309,9 +309,9 @@ namespace __gnu_cxx ...@@ -309,9 +309,9 @@ namespace __gnu_cxx
const _Alloc& __a); const _Alloc& __a);
~__rc_string_base() ~__rc_string_base()
{ _M_dispose(_M_get_allocator()); } { _M_dispose(); }
allocator_type const allocator_type&
_M_get_allocator() const _M_get_allocator() const
{ return _M_dataplus; } { return _M_dataplus; }
...@@ -372,9 +372,6 @@ namespace __gnu_cxx ...@@ -372,9 +372,6 @@ namespace __gnu_cxx
// The below implements an exponential growth policy, necessary to // The below implements an exponential growth policy, necessary to
// meet amortized linear time requirements of the library: see // meet amortized linear time requirements of the library: see
// http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html. // 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) if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
__capacity = 2 * __old_capacity; __capacity = 2 * __old_capacity;
...@@ -441,8 +438,7 @@ namespace __gnu_cxx ...@@ -441,8 +438,7 @@ namespace __gnu_cxx
__rc_string_base<_CharT, _Traits, _Alloc>:: __rc_string_base<_CharT, _Traits, _Alloc>::
__rc_string_base(const __rc_string_base& __rcs) __rc_string_base(const __rc_string_base& __rcs)
: _M_dataplus(__rcs._M_get_allocator(), : _M_dataplus(__rcs._M_get_allocator(),
__rcs._M_grab(_Alloc(__rcs._M_get_allocator()), __rcs._M_grab(__rcs._M_get_allocator())) { }
__rcs._M_get_allocator())) { }
template<typename _CharT, typename _Traits, typename _Alloc> template<typename _CharT, typename _Traits, typename _Alloc>
__rc_string_base<_CharT, _Traits, _Alloc>:: __rc_string_base<_CharT, _Traits, _Alloc>::
...@@ -516,7 +512,7 @@ namespace __gnu_cxx ...@@ -516,7 +512,7 @@ namespace __gnu_cxx
} }
template<typename _CharT, typename _Traits, typename _Alloc> template<typename _CharT, typename _Traits, typename _Alloc>
template <typename _InIterator> template<typename _InIterator>
_CharT* _CharT*
__rc_string_base<_CharT, _Traits, _Alloc>:: __rc_string_base<_CharT, _Traits, _Alloc>::
_S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
...@@ -587,9 +583,8 @@ namespace __gnu_cxx ...@@ -587,9 +583,8 @@ namespace __gnu_cxx
{ {
if (_M_rep() != __rcs._M_rep()) if (_M_rep() != __rcs._M_rep())
{ {
const allocator_type __a = _M_get_allocator(); _CharT* __tmp = __rcs._M_grab(_M_get_allocator());
_CharT* __tmp = __rcs._M_grab(__a, __rcs._M_get_allocator()); _M_dispose();
_M_dispose(__a);
_M_data(__tmp); _M_data(__tmp);
} }
} }
...@@ -605,9 +600,9 @@ namespace __gnu_cxx ...@@ -605,9 +600,9 @@ namespace __gnu_cxx
if (__res < _M_length()) if (__res < _M_length())
__res = _M_length(); __res = _M_length();
const allocator_type __a = _M_get_allocator(); _CharT* __tmp = _M_rep()->_M_clone(_M_get_allocator(),
_CharT* __tmp = _M_rep()->_M_clone(__a, __res - _M_length()); __res - _M_length());
_M_dispose(__a); _M_dispose();
_M_data(__tmp); _M_data(__tmp);
} }
} }
...@@ -624,8 +619,8 @@ namespace __gnu_cxx ...@@ -624,8 +619,8 @@ namespace __gnu_cxx
if (__new_size > _M_capacity() || _M_is_shared()) if (__new_size > _M_capacity() || _M_is_shared())
{ {
// Must reallocate. // Must reallocate.
const allocator_type __a = _M_get_allocator(); _Rep* __r = _Rep::_S_create(__new_size, _M_capacity(),
_Rep* __r = _Rep::_S_create(__new_size, _M_capacity(), __a); _M_get_allocator());
if (__pos) if (__pos)
_S_copy(__r->_M_refdata(), _M_data(), __pos); _S_copy(__r->_M_refdata(), _M_data(), __pos);
...@@ -633,7 +628,7 @@ namespace __gnu_cxx ...@@ -633,7 +628,7 @@ namespace __gnu_cxx
_S_copy(__r->_M_refdata() + __pos + __len2, _S_copy(__r->_M_refdata() + __pos + __len2,
_M_data() + __pos + __len1, __how_much); _M_data() + __pos + __len1, __how_much);
_M_dispose(__a); _M_dispose();
_M_data(__r->_M_refdata()); _M_data(__r->_M_refdata());
} }
else if (__how_much && __len1 != __len2) else if (__how_much && __len1 != __len2)
......
...@@ -74,8 +74,8 @@ namespace __gnu_cxx ...@@ -74,8 +74,8 @@ namespace __gnu_cxx
union union
{ {
_CharT _M_local_data[_S_local_capacity + 1]; _CharT _M_local_data[_S_local_capacity + 1];
size_type _M_allocated_capacity; size_type _M_allocated_capacity;
}; };
void void
...@@ -99,7 +99,7 @@ namespace __gnu_cxx ...@@ -99,7 +99,7 @@ namespace __gnu_cxx
_M_create(size_type&, size_type); _M_create(size_type&, size_type);
void void
_M_dispose() throw() _M_dispose()
{ {
if (!_M_is_local()) if (!_M_is_local())
_M_destroy(_M_allocated_capacity + 1); _M_destroy(_M_allocated_capacity + 1);
...@@ -110,7 +110,7 @@ namespace __gnu_cxx ...@@ -110,7 +110,7 @@ namespace __gnu_cxx
// _M_construct_aux is used to implement the 21.3.1 para 15 which // _M_construct_aux is used to implement the 21.3.1 para 15 which
// requires special behaviour if _InIterator is an integral type // requires special behaviour if _InIterator is an integral type
template<class _InIterator> template<typename _InIterator>
void void
_M_construct_aux(_InIterator __beg, _InIterator __end, __false_type) _M_construct_aux(_InIterator __beg, _InIterator __end, __false_type)
{ {
...@@ -118,13 +118,13 @@ namespace __gnu_cxx ...@@ -118,13 +118,13 @@ namespace __gnu_cxx
_M_construct(__beg, __end, _Tag()); _M_construct(__beg, __end, _Tag());
} }
template<class _InIterator> template<typename _InIterator>
void void
_M_construct_aux(_InIterator __beg, _InIterator __end, __true_type) _M_construct_aux(_InIterator __beg, _InIterator __end, __true_type)
{ _M_construct(static_cast<size_type>(__beg), { _M_construct(static_cast<size_type>(__beg),
static_cast<value_type>(__end)); } static_cast<value_type>(__end)); }
template<class _InIterator> template<typename _InIterator>
void void
_M_construct(_InIterator __beg, _InIterator __end) _M_construct(_InIterator __beg, _InIterator __end)
{ {
...@@ -133,14 +133,14 @@ namespace __gnu_cxx ...@@ -133,14 +133,14 @@ namespace __gnu_cxx
} }
// For Input Iterators, used in istreambuf_iterators, etc. // For Input Iterators, used in istreambuf_iterators, etc.
template<class _InIterator> template<typename _InIterator>
void void
_M_construct(_InIterator __beg, _InIterator __end, _M_construct(_InIterator __beg, _InIterator __end,
std::input_iterator_tag); std::input_iterator_tag);
// For forward_iterators up to random_access_iterators, used for // For forward_iterators up to random_access_iterators, used for
// string::iterator, _CharT*, etc. // string::iterator, _CharT*, etc.
template<class _FwdIterator> template<typename _FwdIterator>
void void
_M_construct(_FwdIterator __beg, _FwdIterator __end, _M_construct(_FwdIterator __beg, _FwdIterator __end,
std::forward_iterator_tag); std::forward_iterator_tag);
...@@ -202,7 +202,7 @@ namespace __gnu_cxx ...@@ -202,7 +202,7 @@ namespace __gnu_cxx
~__sso_string_base() ~__sso_string_base()
{ _M_dispose(); } { _M_dispose(); }
allocator_type const allocator_type&
_M_get_allocator() const _M_get_allocator() const
{ return _M_dataplus; } { return _M_dataplus; }
...@@ -392,7 +392,7 @@ namespace __gnu_cxx ...@@ -392,7 +392,7 @@ namespace __gnu_cxx
} }
template<typename _CharT, typename _Traits, typename _Alloc> template<typename _CharT, typename _Traits, typename _Alloc>
template <typename _InIterator> template<typename _InIterator>
void void
__sso_string_base<_CharT, _Traits, _Alloc>:: __sso_string_base<_CharT, _Traits, _Alloc>::
_M_construct(_InIterator __beg, _InIterator __end, _M_construct(_InIterator __beg, _InIterator __end,
......
...@@ -160,7 +160,7 @@ namespace __gnu_cxx ...@@ -160,7 +160,7 @@ namespace __gnu_cxx
// _S_copy_chars is a separate template to permit specialization // _S_copy_chars is a separate template to permit specialization
// to optimize for the common case of pointers as iterators. // to optimize for the common case of pointers as iterators.
template<class _Iterator> template<typename _Iterator>
static void static void
_S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2) _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment