* [v3] Minor tweak to the last commit
@ 2004-10-25 15:49 Paolo Carlini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Carlini @ 2004-10-25 15:49 UTC (permalink / raw)
To: 'gcc-patches@gcc.gnu.org'
[-- Attachment #1: Type: text/plain, Size: 62 bytes --]
Hi,
tested x86-linux, committed.
Paolo.
//////////////////
[-- Attachment #2: CL_disjunct --]
[-- Type: text/plain, Size: 225 bytes --]
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.
[-- Attachment #3: patch_disjunct --]
[-- Type: text/plain, Size: 2835 bytes --]
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* [v3] Minor tweak to the last commit
@ 2008-08-21 2:16 Paolo Carlini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Carlini @ 2008-08-21 2:16 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++
[-- Attachment #1: Type: text/plain, Size: 75 bytes --]
Hi,
tested x86_64-linux, committed to mainline.
Paolo.
////////////////
[-- Attachment #2: CL_33979_t1.txt --]
[-- Type: text/plain, Size: 240 bytes --]
2008-08-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/char_traits.h (char_traits<char16_t>::
assign(char_type*, size_t, char_type), char_traits<char32_t>::
assign(char_type*, size_t, char_type)): For now, just open-code.
[-- Attachment #3: patch_33979_t1.txt --]
[-- Type: text/plain, Size: 4482 bytes --]
Index: include/bits/char_traits.h
===================================================================
*** include/bits/char_traits.h (revision 139341)
--- include/bits/char_traits.h (working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 298,304 ****
{ return __c1 == __c2; }
static int_type
! eof() { return static_cast<int_type>(_CHAR_TRAITS_EOF); }
static int_type
not_eof(const int_type& __c)
--- 298,305 ----
{ return __c1 == __c2; }
static int_type
! eof()
! { return static_cast<int_type>(_CHAR_TRAITS_EOF); }
static int_type
not_eof(const int_type& __c)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 354,370 ****
{ return wmemset(__s, __a, __n); }
static char_type
! to_char_type(const int_type& __c) { return char_type(__c); }
static int_type
! to_int_type(const char_type& __c) { return int_type(__c); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return __c1 == __c2; }
static int_type
! eof() { return static_cast<int_type>(WEOF); }
static int_type
not_eof(const int_type& __c)
--- 355,374 ----
{ return wmemset(__s, __a, __n); }
static char_type
! to_char_type(const int_type& __c)
! { return char_type(__c); }
static int_type
! to_int_type(const char_type& __c)
! { return int_type(__c); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return __c1 == __c2; }
static int_type
! eof()
! { return static_cast<int_type>(WEOF); }
static int_type
not_eof(const int_type& __c)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 447,469 ****
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
! {
! std::fill_n(__s, __n, __a);
return __s;
}
static char_type
! to_char_type(const int_type& __c) { return char_type(__c); }
static int_type
! to_int_type(const char_type& __c) { return int_type(__c); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return __c1 == __c2; }
static int_type
! eof() { return static_cast<int_type>(-1); }
static int_type
not_eof(const int_type& __c)
--- 451,477 ----
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
! {
! for (size_t __i = 0; __i < __n; ++__i)
! assign(__s[__i], __a);
return __s;
}
static char_type
! to_char_type(const int_type& __c)
! { return char_type(__c); }
static int_type
! to_int_type(const char_type& __c)
! { return int_type(__c); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return __c1 == __c2; }
static int_type
! eof()
! { return static_cast<int_type>(-1); }
static int_type
not_eof(const int_type& __c)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 537,558 ****
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
{
! std::fill_n(__s, __n, __a);
return __s;
}
static char_type
! to_char_type(const int_type& __c) { return char_type(__c); }
static int_type
! to_int_type(const char_type& __c) { return int_type(__c); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return __c1 == __c2; }
static int_type
! eof() { return static_cast<int_type>(-1); }
static int_type
not_eof(const int_type& __c)
--- 545,570 ----
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
{
! for (size_t __i = 0; __i < __n; ++__i)
! assign(__s[__i], __a);
return __s;
}
static char_type
! to_char_type(const int_type& __c)
! { return char_type(__c); }
static int_type
! to_int_type(const char_type& __c)
! { return int_type(__c); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return __c1 == __c2; }
static int_type
! eof()
! { return static_cast<int_type>(-1); }
static int_type
not_eof(const int_type& __c)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-21 1:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-25 15:49 [v3] Minor tweak to the last commit Paolo Carlini
2008-08-21 2:16 Paolo Carlini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).