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]

[Patchlet/RFC] To basic_string::_Rep::_M_destroy


Hi,

this is something I have been able to notice only thanks to the
ongoing restructuring work: basically, when _M_destroy is called,
either it's a "real" string, dynamically allocated, that is (case
of the _S_construct(s)) or the caller is _M_dispose, which already
checks at the outset for _S_empty_rep.

In the branch, this simplification is not giving any problem, and
since seems so trivial, I'd like to apply it to mainline too... if
nobody spots something wrong with it, indeed.

I'm finishing regtesting on x86/x86_64-linux.

Paolo.

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

	* include/bits/basic_string.tcc (_Rep::_M_destroy): Don't
	check for this == &_S_empty_rep, it's always false, here.
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-11-29 13:59:51.000000000 +0100
+++ libstdc++-v3/include/bits/basic_string.tcc	2005-02-21 19:20:12.000000000 +0100
@@ -1,6 +1,6 @@
 // Components for manipulating sequences of characters -*- C++ -*-
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -425,10 +425,6 @@
     basic_string<_CharT, _Traits, _Alloc>::_Rep::
     _M_destroy(const _Alloc& __a) throw ()
     {
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
-      if (this == &_S_empty_rep())
-	return;
-#endif
       const size_type __size = sizeof(_Rep_base) +
 	                       (this->_M_capacity + 1) * sizeof(_CharT);
       _Raw_bytes_alloc(__a).deallocate(reinterpret_cast<char*>(this), __size);

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