basic_string.tcc (_S_construct(size_type, _CharT, const _Alloc&)): Remove redundant try/catch.

2004-01-19  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/basic_string.tcc (_S_construct(size_type,
	_CharT, const _Alloc&)): Remove redundant try/catch.
	(_M_mutate(size_type, size_type, size_type)): Ditto.
	(_M_clone(const _Alloc&, size_type)): Ditto.

From-SVN: r76141
This commit is contained in:
Paolo Carlini 2004-01-19 08:53:32 +00:00 committed by Paolo Carlini
parent 8c80adb754
commit 954b12d2dc
2 changed files with 20 additions and 35 deletions

View File

@ -1,3 +1,10 @@
2004-01-19 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (_S_construct(size_type,
_CharT, const _Alloc&)): Remove redundant try/catch.
(_M_mutate(size_type, size_type, size_type)): Ditto.
(_M_clone(const _Alloc&, size_type)): Ditto.
2004-01-18 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (c_str()): Simplify, due to

View File

@ -182,16 +182,9 @@ namespace std
// Check for out_of_range and length_error exceptions.
_Rep* __r = _Rep::_S_create(__n, __a);
try
{
if (__n)
traits_type::assign(__r->_M_refdata(), __n, __c);
}
catch(...)
{
__r->_M_destroy(__a);
__throw_exception_again;
}
if (__n)
traits_type::assign(__r->_M_refdata(), __n, __c);
__r->_M_length = __n;
__r->_M_refdata()[__n] = _Rep::_S_terminal; // grrr
return __r->_M_refdata();
@ -442,19 +435,13 @@ namespace std
__new_size : 2*capacity(), __a);
else
__r = _Rep::_S_create(__new_size, __a);
try
{
if (__pos)
traits_type::copy(__r->_M_refdata(), _M_data(), __pos);
if (__how_much)
traits_type::copy(__r->_M_refdata() + __pos + __len2,
__src, __how_much);
}
catch(...)
{
__r->_M_dispose(get_allocator());
__throw_exception_again;
}
if (__pos)
traits_type::copy(__r->_M_refdata(), _M_data(), __pos);
if (__how_much)
traits_type::copy(__r->_M_refdata() + __pos + __len2,
__src, __how_much);
_M_rep()->_M_dispose(__a);
_M_data(__r->_M_refdata());
}
@ -603,18 +590,9 @@ namespace std
__r = _Rep::_S_create(__requested_cap, __alloc);
if (this->_M_length)
{
try
{
traits_type::copy(__r->_M_refdata(), _M_refdata(),
this->_M_length);
}
catch(...)
{
__r->_M_destroy(__alloc);
__throw_exception_again;
}
}
traits_type::copy(__r->_M_refdata(), _M_refdata(),
this->_M_length);
__r->_M_length = this->_M_length;
__r->_M_refdata()[this->_M_length] = _Rep::_S_terminal;
return __r->_M_refdata();