locale_facets.tcc (__pad<>::_S_pad): Improve performance-wise...

2003-10-06  Paolo Carlini  <pcarlini@unitus.it>

	* include/bits/locale_facets.tcc (__pad<>::_S_pad):
	Improve performance-wise: avoid one traits::copy, avoid
	the __builtin_alloca, streamline.

From-SVN: r72164
This commit is contained in:
Paolo Carlini 2003-10-06 21:46:21 +02:00 committed by Paolo Carlini
parent d54f735472
commit e4f7d0a18f
2 changed files with 18 additions and 28 deletions

View File

@ -1,3 +1,9 @@
2003-10-06 Paolo Carlini <pcarlini@unitus.it>
* include/bits/locale_facets.tcc (__pad<>::_S_pad):
Improve performance-wise: avoid one traits::copy, avoid
the __builtin_alloca, streamline.
2003-10-05 Paolo Carlini <pcarlini@unitus.it>
* include/bits/locale_facets.tcc

View File

@ -2207,25 +2207,19 @@ namespace std
const streamsize __newlen,
const streamsize __oldlen, const bool __num)
{
size_t __plen = static_cast<size_t>(__newlen - __oldlen);
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __plen));
_Traits::assign(__pads, __plen, __fill);
_CharT* __beg;
_CharT* __end;
size_t __mod = 0;
size_t __beglen; //either __plen or __oldlen
ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
const size_t __plen = static_cast<size_t>(__newlen - __oldlen);
const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
// Padding last.
if (__adjust == ios_base::left)
{
// Padding last.
__beg = const_cast<_CharT*>(__olds);
__beglen = __oldlen;
__end = __pads;
_Traits::copy(__news, const_cast<_CharT*>(__olds), __oldlen);
_Traits::assign(__news + __oldlen, __plen, __fill);
return;
}
else if (__adjust == ios_base::internal && __num)
size_t __mod = 0;
if (__adjust == ios_base::internal && __num)
{
// Pad after the sign, if there is one.
// Pad after 0[xX], if there is one.
@ -2254,20 +2248,10 @@ namespace std
++__news;
}
// else Padding first.
__beg = __pads;
__beglen = __plen;
__end = const_cast<_CharT*>(__olds + __mod);
}
else
{
// Padding first.
__beg = __pads;
__beglen = __plen;
__end = const_cast<_CharT*>(__olds);
}
_Traits::copy(__news, __beg, __beglen);
_Traits::copy(__news + __beglen, __end, __newlen - __beglen - __mod);
_Traits::assign(__news, __plen, __fill);
_Traits::copy(__news + __plen, const_cast<_CharT*>(__olds + __mod),
__oldlen - __mod);
}
template<typename _CharT>