This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[v3] Move out of line the _M_replace_* helpers
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 27 Oct 2004 14:11:52 +0200
- Subject: [v3] Move out of line the _M_replace_* helpers
Hi,
tested x86-linux, committed to mainline.
(on x86, dynamically linked testcases parsing floats become
a tad faster (~2%), performance neutral otherwise in all my
tests; statically linked executables slighlty smaller)
Paolo.
//////////////
2004-10-27 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (_M_replace_aux, _M_replace_safe):
Move out of line...
* include/bits/basic_string.tcc: ... here.
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-27 00:55:58.000000000 +0200
+++ libstdc++-v3/include/bits/basic_string.h 2004-10-27 13:24:28.000000000 +0200
@@ -1435,24 +1435,11 @@
basic_string&
_M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
- _CharT __c)
- {
- _M_check_length(__n1, __n2, "basic_string::_M_replace_aux");
- _M_mutate(__pos1, __n1, __n2);
- if (__n2)
- _M_assign(_M_data() + __pos1, __n2, __c);
- return *this;
- }
+ _CharT __c);
basic_string&
_M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
- size_type __n2)
- {
- _M_mutate(__pos1, __n1, __n2);
- if (__n2)
- _M_copy(_M_data() + __pos1, __s, __n2);
- return *this;
- }
+ size_type __n2);
// _S_construct_aux is used to implement the 21.3.1 para 15 which
// requires special behaviour if _InIter is an integral type
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-27 00:56:07.000000000 +0200
+++ libstdc++-v3/include/bits/basic_string.tcc 2004-10-27 13:24:34.000000000 +0200
@@ -620,7 +620,32 @@
return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(),
__s.size());
}
-
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
+ _CharT __c)
+ {
+ _M_check_length(__n1, __n2, "basic_string::_M_replace_aux");
+ _M_mutate(__pos1, __n1, __n2);
+ if (__n2)
+ _M_assign(_M_data() + __pos1, __n2, __c);
+ return *this;
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
+ size_type __n2)
+ {
+ _M_mutate(__pos1, __n1, __n2);
+ if (__n2)
+ _M_copy(_M_data() + __pos1, __s, __n2);
+ return *this;
+ }
+
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>
operator+(const _CharT* __lhs,