public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [v3] Tweak basic_string overloads on initializer_list...
@ 2009-10-15  2:23 Paolo Carlini
  0 siblings, 0 replies; only message in thread
From: Paolo Carlini @ 2009-10-15  2:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++

[-- Attachment #1: Type: text/plain, Size: 109 bytes --]

... to avoid unnecessary instantiations in the library.

Tested x86_64-linux, committed to mainline.

Paolo.

[-- Attachment #2: CL_il --]
[-- Type: text/plain, Size: 476 bytes --]

2009-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/basic_string.h (operator+=(initializer_list<>),
	append(initializer_list<>)): Forward to the append overload taking
	a const CharT* pointer and a size, thus avoiding instantiating
	unnecessarily in the built library the overload taking a pair of
	iterators.
	(operator=(initializer_list<>), assign(initializer_list<>)): Likewise
	for assign.
	(insert(iterator, initializer_list<>): Likewise for insert.



[-- Attachment #3: patch_il --]
[-- Type: text/plain, Size: 1583 bytes --]

Index: include/bits/basic_string.h
===================================================================
--- include/bits/basic_string.h	(revision 152771)
+++ include/bits/basic_string.h	(working copy)
@@ -540,7 +540,7 @@
       basic_string&
       operator=(initializer_list<_CharT> __l)
       {
-	this->assign (__l.begin(), __l.end());
+	this->assign(__l.begin(), __l.size());
 	return *this;
       }
 #endif // __GXX_EXPERIMENTAL_CXX0X__
@@ -860,7 +860,7 @@
        */
       basic_string&
       operator+=(initializer_list<_CharT> __l)
-      { return this->append(__l.begin(), __l.end()); }
+      { return this->append(__l.begin(), __l.size()); }
 #endif // __GXX_EXPERIMENTAL_CXX0X__
 
       /**
@@ -926,7 +926,7 @@
        */
       basic_string&
       append(initializer_list<_CharT> __l)
-      { return this->append(__l.begin(), __l.end()); }
+      { return this->append(__l.begin(), __l.size()); }
 #endif // __GXX_EXPERIMENTAL_CXX0X__
 
       /**
@@ -1045,7 +1045,7 @@
        */
       basic_string&
       assign(initializer_list<_CharT> __l)
-      { return this->assign(__l.begin(), __l.end()); }
+      { return this->assign(__l.begin(), __l.size()); }
 #endif // __GXX_EXPERIMENTAL_CXX0X__
 
       /**
@@ -1089,7 +1089,10 @@
        */
       void
       insert(iterator __p, initializer_list<_CharT> __l)
-      { this->insert(__p, __l.begin(), __l.end()); }
+      {
+	_GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
+	this->insert(__p - _M_ibegin(), __l.begin(), __l.size());
+      }
 #endif // __GXX_EXPERIMENTAL_CXX0X__
 
       /**

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-10-15  1:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-15  2:23 [v3] Tweak basic_string overloads on initializer_list 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).