stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r660311 - /stdcxx/branches/4.2.x/include/valarray.cc
Date Mon, 26 May 2008 21:21:56 GMT
Author: sebor
Date: Mon May 26 14:21:53 2008
New Revision: 660311

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

	Merged revs 650367 and 650584 from trunk.

	2008-04-22  Martin Sebor  <sebor@roguewave.com>

	* include/valarray.cc (shift, cshift): Consistently used copy- rather
	than direct-initialization to work around a gcc 3.2 bug (regression
	introduced in rev 650367).
	Introduced a temporary for a potential efficiency gain.

	2008-04-21  Martin Sebor  <sebor@roguewave.com>

	* include/valarray.cc (shift, cshift): Removed assumptions about
	value_type being constructible from int. Revealed by regression
	test for STDCXX-316 committed in rev 650366.
	(cshift): Replaced a functional cast involving _RWSTD_PTRDIFF_T
	with a C-style one in case the macro expands to something like
	"signed long."

Modified:
    stdcxx/branches/4.2.x/include/valarray.cc

Modified: stdcxx/branches/4.2.x/include/valarray.cc
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/valarray.cc?rev=660311&r1=660310&r2=660311&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/include/valarray.cc (original)
+++ stdcxx/branches/4.2.x/include/valarray.cc Mon May 26 14:21:53 2008
@@ -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-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -36,10 +36,15 @@
     if (0 == __n)
         return *this;
 
-    if (size () <= (_RWSTD_SIZE_T)(__n < 0 ? -__n : __n))
-        return valarray (_TypeT (0), size ());
+    const _RWSTD_SIZE_T __size = size ();
+
+    if (__size <= (_RWSTD_SIZE_T)(__n < 0 ? -__n : __n))
+        return valarray (__size);
         
-    _RW::__rw_array <_TypeT> __tmp (_TypeT (0), size ());
+    // use copy- rather than direct-initialization to work around
+    // a gcc 3.2 bug
+    _RW::__rw_array<_TypeT> __tmp =
+        _RW::__rw_array<_TypeT>(_TypeT (), __size);
 
     // 26.3.2.7, p5 - negative n shifts right, positive left
     if (__n < 0)
@@ -54,15 +59,20 @@
 template <class _TypeT>
 valarray<_TypeT> valarray<_TypeT>::cshift (int __n) const
 {
+    const _RWSTD_SIZE_T __size = size ();
+
     // compute non-negative modulus - the sign of (a % b) is
     // implementation-defined if either argument is negative (5.6, p4)
-    _RWSTD_PTRDIFF_T __mod = size () ? __n % _RWSTD_PTRDIFF_T (size ()) : 0;
+    _RWSTD_PTRDIFF_T __mod = __size ? __n % (_RWSTD_PTRDIFF_T)__size : 0;
     _RWSTD_SIZE_T    __rem = __mod < 0 ? -__mod : __mod;
 
     if (0 == __rem)
         return *this;
 
-    _RW::__rw_array<_TypeT> __tmp (_TypeT (0), size ());
+    // use copy- rather than direct-initialization to work around
+    // a gcc 3.2 bug
+    _RW::__rw_array<_TypeT> __tmp =
+        _RW::__rw_array<_TypeT>(_TypeT (), __size);
 
     // 26.3.2.7, p7 - negative n rotates right, positive left
     rotate_copy (_C_array.begin (),



Mime
View raw message