stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r778845 - in /stdcxx/branches/4.3.x/src: iosdata.h iostore.cpp iso2022.cpp num_put.cpp
Date Tue, 26 May 2009 18:55:28 GMT
Author: sebor
Date: Tue May 26 18:55:28 2009
New Revision: 778845

URL: http://svn.apache.org/viewvc?rev=778845&view=rev
Log:
2009-05-26  Martin Sebor  <sebor@apache.org>

	Merged revs 778780, 778800, and 778803 from 4.2.x.

	STDCXX-1036
	* src/iosdata.h (ios_base::_C_usr_data::_C_alloc,
	ios_base::_C_usr_data::_C_dealloc): Moved functions from here...
	* src/iostore.cpp: ...to here and outlined to silence gcc 4.4 -Winline
	warnings. 
	* src/num_put.cpp (__rw_dtoa): Called the unsigned overload of __rw_dtoa
	only once to avoid gcc 4.4 -Winline warning (and for a small efficiency
	gain).
	* src/iso2022.cpp (__rw_allocate_state): Outlined rarely called
	function to silence gcc 4.4 -Winline warnings: inlining failed:
	call is unlikely and code size would grow.

Modified:
    stdcxx/branches/4.3.x/src/iosdata.h
    stdcxx/branches/4.3.x/src/iostore.cpp
    stdcxx/branches/4.3.x/src/iso2022.cpp
    stdcxx/branches/4.3.x/src/num_put.cpp

Modified: stdcxx/branches/4.3.x/src/iosdata.h
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/iosdata.h?rev=778845&r1=778844&r2=778845&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/iosdata.h (original)
+++ stdcxx/branches/4.3.x/src/iosdata.h Tue May 26 18:55:28 2009
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2006 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -30,8 +30,6 @@
 #define _RWSTD_IOSDATA_H_INCLUDED
 
 
-#include <string.h>
-
 #include <rw/_iosbase.h>
 #include <rw/_defs.h>
 
@@ -68,66 +66,6 @@
     static _C_usr_data _C_std_usr_data [2];
 };
 
-
-inline /* static */ ios_base::_C_usr_data*
-ios_base::_C_usr_data::_C_alloc (_C_fire_fun pfire)
-{
-    _TRY {
-        // rely on 0-initialization of PODs
-        _C_usr_data* const pdata = new _C_usr_data ();
-
-#ifdef _RWSTD_NO_NEW_THROWS
-
-        if (!pdata)
-            return 0;
-
-#endif   // _RWSTD_NO_NEW_THROWS
-
-        _RWSTD_ASSERT (0 != pdata);
-
-#ifndef _RWSTD_NO_POD_ZERO_INIT
-
-        // assert that the POD ctor above zeroed out all members
-        _RWSTD_ASSERT (!pdata->_C_tie);
-        _RWSTD_ASSERT (!pdata->_C_iarray);
-        _RWSTD_ASSERT (!pdata->_C_parray);
-        _RWSTD_ASSERT (!pdata->_C_cbarray);
-        _RWSTD_ASSERT (!pdata->_C_isize);
-        _RWSTD_ASSERT (!pdata->_C_psize);
-        _RWSTD_ASSERT (!pdata->_C_cbsize);
-
-#else   // if defined (_RWSTD_NO_POD_ZERO_INIT)
-
-        memset (pdata, 0, sizeof *pdata);
-
-#endif   // _RWSTD_NO_POD_ZERO_INIT
-
-        pdata->_C_fire = pfire;
-
-        return pdata;
-    }
-    _CATCH (...) {
-        return 0;
-    }
-}
-
-
-inline /* static */ void
-ios_base::_C_usr_data::_C_dealloc (_C_usr_data *ptr)
-{
-    if (ptr) {
-        operator delete (ptr->_C_iarray);
-        operator delete (ptr->_C_parray);
-        operator delete (ptr->_C_cbarray);
-
-        if (   ptr != _C_usr_data::_C_std_usr_data
-            && ptr != _C_usr_data::_C_std_usr_data + 1)
-            delete ptr;
-    }
-}
-
-
 }   // namespace std
 
-
 #endif   // _RWSTD_IOSDATA_H_INCLUDED

Modified: stdcxx/branches/4.3.x/src/iostore.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/iostore.cpp?rev=778845&r1=778844&r2=778845&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/iostore.cpp (original)
+++ stdcxx/branches/4.3.x/src/iostore.cpp Tue May 26 18:55:28 2009
@@ -84,6 +84,64 @@
 _RWSTD_NAMESPACE (std) {
 
 
+/* static */ ios_base::_C_usr_data*
+ios_base::_C_usr_data::_C_alloc (_C_fire_fun pfire)
+{
+    _TRY {
+        // rely on zero-initialization of PODs
+        _C_usr_data* const pdata = new _C_usr_data ();
+
+#ifdef _RWSTD_NO_NEW_THROWS
+
+        if (!pdata)
+            return 0;
+
+#endif   // _RWSTD_NO_NEW_THROWS
+
+        _RWSTD_ASSERT (0 != pdata);
+
+#ifndef _RWSTD_NO_POD_ZERO_INIT
+
+        // assert that the POD ctor above zeroed out all members
+        _RWSTD_ASSERT (!pdata->_C_tie);
+        _RWSTD_ASSERT (!pdata->_C_iarray);
+        _RWSTD_ASSERT (!pdata->_C_parray);
+        _RWSTD_ASSERT (!pdata->_C_cbarray);
+        _RWSTD_ASSERT (!pdata->_C_isize);
+        _RWSTD_ASSERT (!pdata->_C_psize);
+        _RWSTD_ASSERT (!pdata->_C_cbsize);
+
+#else   // if defined (_RWSTD_NO_POD_ZERO_INIT)
+
+        memset (pdata, 0, sizeof *pdata);
+
+#endif   // _RWSTD_NO_POD_ZERO_INIT
+
+        pdata->_C_fire = pfire;
+
+        return pdata;
+    }
+    _CATCH (...) {
+        return 0;
+    }
+}
+
+
+/* static */ void
+ios_base::_C_usr_data::_C_dealloc (_C_usr_data *ptr)
+{
+    if (ptr) {
+        operator delete (ptr->_C_iarray);
+        operator delete (ptr->_C_parray);
+        operator delete (ptr->_C_cbarray);
+
+        if (   ptr != _C_usr_data::_C_std_usr_data
+            && ptr != _C_usr_data::_C_std_usr_data + 1)
+            delete ptr;
+    }
+}
+
+
 /* static */ int ios_base::xalloc ()
 {
     // outlined to hide implementation details

Modified: stdcxx/branches/4.3.x/src/iso2022.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/iso2022.cpp?rev=778845&r1=778844&r2=778845&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/iso2022.cpp (original)
+++ stdcxx/branches/4.3.x/src/iso2022.cpp Tue May 26 18:55:28 2009
@@ -1,6 +1,6 @@
 /***************************************************************************
  *
- * rw_iso2022.cpp
+ * iso2022.cpp
  *
  * $Id$
  *
@@ -416,8 +416,8 @@
 // returns an index in the array of state structures or -1 if none
 // is available; ISO-2022-JP and ISO-2022-JP-2 assume different
 // initializations
-static inline
-int __rw_allocate_state ()
+static inline int
+__rw_allocate_state ()
 {
     _RWSTD_MT_CLASS_GUARD (__rw_iso2022_state_t);
 
@@ -434,8 +434,8 @@
 // deallocates state and makes it available for future conversions
 // if `initial_only' is non-zero suceeds only if the `iso_state'
 // argument represents an initial shift state
-static inline
-void __rw_deallocate_state (__rw_iso2022_state_t &iso_state,
+static void
+__rw_deallocate_state (__rw_iso2022_state_t &iso_state,
                             _RWSTD_MBSTATE_T     &state,
                             bool                  initial_only)
 {

Modified: stdcxx/branches/4.3.x/src/num_put.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/num_put.cpp?rev=778845&r1=778844&r2=778845&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/num_put.cpp (original)
+++ stdcxx/branches/4.3.x/src/num_put.cpp Tue May 26 18:55:28 2009
@@ -153,7 +153,7 @@
 
     const _RWSTD_SIZE_T len = begin - end;
 
-   memmove (buf, end, len);
+    memmove (buf, end, len);
 
     return len;
 }
@@ -185,7 +185,7 @@
 
     const _RWSTD_SIZE_T len = begin - end;
 
-   memmove (buf, end, len);
+    memmove (buf, end, len);
 
     return len;
 }
@@ -194,13 +194,23 @@
 static inline _RWSTD_SIZE_T
 __rw_dtoa (char *buf, _LLong i, unsigned flags)
 {
+    size_t n;
+
     if (i < 0) {
+        // prepend the minus sign and clear the showpos bit in flags
+        // and the sign bit in the number
         flags  &= ~_RWSTD_IOS_SHOWPOS;
         *buf++  = '-';
-        return 1 + __rw_dtoa (buf, _RWSTD_STATIC_CAST (_ULLong, -i), flags);
+
+        i = -i;
+
+        // remember to add 1 for the minus sign
+        n = 1;
     }
-        
-    return __rw_dtoa (buf, _RWSTD_STATIC_CAST (_ULLong, i), flags);
+    else
+        n = 0;   // no sign here
+
+    return n + __rw_dtoa (buf, _RWSTD_STATIC_CAST (_ULLong, i), flags);
 }
 
 
@@ -312,7 +322,7 @@
 }
 
 
-static  inline _RWSTD_SIZE_T
+static inline size_t
 __rw_dtoa (char *buf, unsigned long i, unsigned flags)
 {
     // get the maximum number of decimal digits for an unsigned long
@@ -341,7 +351,7 @@
     // move the contents of the buffer to the beginning
     const _RWSTD_SIZE_T len = begin - end;
 
-   memmove (buf, end, len);
+    memmove (buf, end, len);
 
     return len;
 }
@@ -350,14 +360,23 @@
 static inline _RWSTD_SIZE_T
 __rw_dtoa (char *buf, long i, unsigned flags)
 {
+    size_t n;
+
     if (i < 0) {
+        // prepend the minus sign and clear the showpos bit in flags
+        // and the sign bit in the number
         flags  &= ~_RWSTD_IOS_SHOWPOS;
         *buf++  = '-';
-        return 1 + __rw_dtoa (buf, _RWSTD_STATIC_CAST (unsigned long, -i),
-                              flags);
+
+        i = -i;
+
+        // remember to add 1 for the minus sign
+        n = 1;
     }
-        
-    return __rw_dtoa (buf, _RWSTD_STATIC_CAST (unsigned long, i), flags);
+    else
+        n = 0;   // no sign here
+
+    return n + __rw_dtoa (buf, _RWSTD_STATIC_CAST (unsigned long, i), flags);
 }
 
 



Mime
View raw message