This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[v3] Minor tweak to the last commit


Hi,

tested x86-linux, committed.

Paolo.

//////////////////
2004-10-25  Paolo Carlini  <pcarlini@suse.de>
	
	* include/bits/basic_string.h (_Rep::_M_is_safe): Move to
	basic_string as _M_disjunct, adjust to take only __s.
	* include/bits/basic_string.tcc: Adjust consistently callers. 
diff -urN libstdc++-v3-orig/include/bits/basic_string.h libstdc++-v3/include/bits/basic_string.h
--- libstdc++-v3-orig/include/bits/basic_string.h	2004-10-24 10:35:29.000000000 +0200
+++ libstdc++-v3/include/bits/basic_string.h	2004-10-25 17:10:49.000000000 +0200
@@ -185,14 +185,6 @@
 	_M_is_shared() const
         { return this->_M_refcount > 0; }
 
-	// True if source and destination do not overlap.
-	bool
-	_M_is_safe(const _CharT* __data, const _CharT* __s) const
-	{
-	  return (less<const _CharT*>()(__s, __data)
-		  || less<const _CharT*>()(__data + this->_M_length, __s));
-	}
-
         void
 	_M_set_leaked()
         { this->_M_refcount = -1; }
@@ -325,6 +317,14 @@
 	return __testoff ? __off : this->size() - __pos;
       }
 
+      // True if _Rep and source do not overlap.
+      bool
+      _M_disjunct(const _CharT* __s) const
+      {
+	return (less<const _CharT*>()(__s, _M_data())
+		|| less<const _CharT*>()(_M_data() + this->size(), __s));
+      }
+
       // When __n = 1 way faster than the general multichar
       // traits_type::copy/move/assign.
       static void
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-10-25 12:36:56.000000000 +0200
+++ libstdc++-v3/include/bits/basic_string.tcc	2004-10-25 17:11:33.000000000 +0200
@@ -246,7 +246,7 @@
     {
       __glibcxx_requires_string_len(__s, __n);
       _M_check_length(this->size(), __n, "basic_string::assign");
-      if (_M_rep()->_M_is_safe(_M_data(), __s) || _M_rep()->_M_is_shared())
+      if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
 	return _M_replace_safe(size_type(0), this->size(), __s, __n);
       else
 	{
@@ -273,7 +273,7 @@
 	  const size_type __len = __n + this->size();
 	  if (__len > this->capacity() || _M_rep()->_M_is_shared())
 	    {
-	      if (_M_rep()->_M_is_safe(_M_data(), __s))
+	      if (_M_disjunct(__s))
 		this->reserve(__len);
 	      else
 		{
@@ -314,7 +314,7 @@
        __glibcxx_requires_string_len(__s, __n);
        _M_check(__pos, "basic_string::insert");
        _M_check_length(size_type(0), __n, "basic_string::insert");
-       if (_M_rep()->_M_is_safe(_M_data(), __s) || _M_rep()->_M_is_shared())
+       if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
          return _M_replace_safe(__pos, size_type(0), __s, __n);
        else
          {
@@ -348,7 +348,7 @@
        __n1 = _M_limit(__pos, __n1);
        _M_check_length(__n1, __n2, "basic_string::replace");
        bool __left;
-       if (_M_rep()->_M_is_safe(_M_data(), __s) || _M_rep()->_M_is_shared())
+       if (_M_disjunct(__s) || _M_rep()->_M_is_shared())
          return _M_replace_safe(__pos, __n1, __s, __n2);
        else if ((__left = __s + __n2 <= _M_data() + __pos)
 		|| _M_data() + __pos + __n1 <= __s)

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