This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Remove redundant try/catch from basic_string


Hi,

regtested on x86-linux. If nobody objects, will commit soon
to mainline.

Paolo.

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

	* include/bits/basic_string.tcc (_S_construct(_InIterator,
	_InIterator, const _Alloc&, forward_iterator_tag)): Remove
	redundant try/catch.
	(_S_construct(size_type, _CharT, const _Alloc&)): Ditto.
	(_M_mutate(size_type, size_type, size_type)): Ditto.
	(_M_clone(const _Alloc&, size_type)): Ditto.
diff -urN libstdc++-v3-orig/include/bits/basic_string.tcc libstdc++-v3/include/bits/basic_string.tcc
--- libstdc++-v3-orig/include/bits/basic_string.tcc	2004-01-18 11:09:59.000000000 +0100
+++ libstdc++-v3/include/bits/basic_string.tcc	2004-01-18 21:27:47.000000000 +0100
@@ -159,15 +159,9 @@
 	
 	// Check for out_of_range and length_error exceptions.
 	_Rep* __r = _Rep::_S_create(__dnew, __a);
-	try 
-	  { _S_copy_chars(__r->_M_refdata(), __beg, __end); }
-	catch(...) 
-	  { 
-	    __r->_M_destroy(__a); 
-	    __throw_exception_again;
-	  }
-	__r->_M_length = __dnew;
+	_S_copy_chars(__r->_M_refdata(), __beg, __end);
 
+	__r->_M_length = __dnew;
 	__r->_M_refdata()[__dnew] = _Rep::_S_terminal;  // grrr.
 	return __r->_M_refdata();
       }
@@ -182,16 +176,9 @@
 
       // 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 +429,13 @@
 				  __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 +584,9 @@
         __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();

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]