OSDN Git Service

2003-10-06 Paolo Carlini <pcarlini@unitus.it>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Oct 2003 19:46:21 +0000 (19:46 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Oct 2003 19:46:21 +0000 (19:46 +0000)
* include/bits/locale_facets.tcc (__pad<>::_S_pad):
Improve performance-wise: avoid one traits::copy, avoid
the __builtin_alloca, streamline.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72164 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc

index 4944684..3b9fe29 100644 (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
index 483d421..7a4acb5 100644 (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>