stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r485943 - in /incubator/stdcxx/trunk: include/valarray src/valarray.cpp
Date Mon, 11 Dec 2006 23:32:31 GMT
Author: sebor
Date: Mon Dec 11 15:32:25 2006
New Revision: 485943

URL: http://svn.apache.org/viewvc?view=rev&rev=485943
Log:
2006-12-11  Martin Sebor  <sebor@roguewave.com>

	STDCXX-309
	* valarray (operator[]): Invoked next_ind() at most once per each
	iteration of the loop.
	* valarray.cpp (next_ind): Returned start() instead of 0 after
	wrapping around.

Modified:
    incubator/stdcxx/trunk/include/valarray
    incubator/stdcxx/trunk/src/valarray.cpp

Modified: incubator/stdcxx/trunk/include/valarray
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/valarray?view=diff&rev=485943&r1=485942&r2=485943
==============================================================================
--- incubator/stdcxx/trunk/include/valarray (original)
+++ incubator/stdcxx/trunk/include/valarray Mon Dec 11 15:32:25 2006
@@ -1472,6 +1472,8 @@
           _C_slice (__s)
         { }
 
+
+
     _RW::__rw_array<value_type>* get_ref_mem_array () const {
         return _C_array;
     }
@@ -1496,6 +1498,7 @@
 
 private:
     gslice_array ();
+    gslice_array<value_type>& operator= (const gslice_array<value_type>&);
 
     _RW::__rw_array<value_type>* _C_array;
     gslice                       _C_slice;
@@ -2115,21 +2118,20 @@
 
 template <class _TypeT> 
 inline valarray<_TypeT>
-valarray<_TypeT>::operator[](const gslice& sl) const
+valarray<_TypeT>::operator[](const gslice& __sl) const
 {
-    _RW::__rw_array <_TypeT> __tmp =
-        _RW::__rw_array <_TypeT>(_TypeT (), sl.ind_numb());
+    const _RWSTD_SIZE_T __maxinx = __sl.ind_numb ();
 
-    gslice *gsl = _RWSTD_CONST_CAST (gslice*, &sl);
+    _RW::__rw_array<_TypeT> __tmp =
+        _RW::__rw_array<_TypeT>(_TypeT (), __maxinx);
 
-    _RWSTD_SIZE_T __i = gsl->next_ind();
-    _RWSTD_SIZE_T __cpt = 0;
+    gslice* const __gsl = _RWSTD_CONST_CAST (gslice*, &__sl);
 
-    while( !sl.is_reseted() )
-    {
-      __tmp[__cpt] = _C_array[__i];
-      __i= gsl->next_ind();
-      __cpt++;
+    for (_RWSTD_SIZE_T __i = 0; __i != __maxinx; ++__i) {
+
+        const _RWSTD_SIZE_T __inx = __gsl->next_ind ();
+
+        __tmp [__i] = _C_array [__inx];
     }
 
     return valarray<_TypeT>(__tmp);

Modified: incubator/stdcxx/trunk/src/valarray.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/src/valarray.cpp?view=diff&rev=485943&r1=485942&r2=485943
==============================================================================
--- incubator/stdcxx/trunk/src/valarray.cpp (original)
+++ incubator/stdcxx/trunk/src/valarray.cpp Mon Dec 11 15:32:25 2006
@@ -2,20 +2,27 @@
  *
  * valaray - Declarations for the Standard Library valarray
  *
- * $Id: //stdlib/dev/source/stdlib/valarray.cpp#15 $
+ * $Id$
  *
  ***************************************************************************
  *
- * Copyright (c) 1994-2005 Quovadx,  Inc., acting through its  Rogue Wave
- * Software division. Licensed under the Apache License, Version 2.0 (the
- * "License");  you may  not use this file except  in compliance with the
- * License.    You    may   obtain   a   copy   of    the   License    at
- * http://www.apache.org/licenses/LICENSE-2.0.    Unless   required    by
- * applicable law  or agreed to  in writing,  software  distributed under
- * the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR
- * CONDITIONS OF  ANY KIND, either  express or implied.  See  the License
- * for the specific language governing permissions  and limitations under
- * the License.
+ * Licensed to the Apache Software  Foundation (ASF) under one or more
+ * contributor  license agreements.  See  the NOTICE  file distributed
+ * with  this  work  for  additional information  regarding  copyright
+ * ownership.   The ASF  licenses this  file to  you under  the Apache
+ * License, Version  2.0 (the  "License"); you may  not use  this file
+ * except in  compliance with the License.   You may obtain  a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the  License is distributed on an  "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
+ * implied.   See  the License  for  the  specific language  governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1994-2006 Rogue Wave Software.
  * 
  **************************************************************************/
 
@@ -36,17 +43,19 @@
 	 
     while (__n && _C_r_length [__n - 1] == _C_length [__n - 1] - 1)
 	--__n;
-     
+
     if (0 == __n) {
         _C_reset    = true;
         _C_r_length = 0;
-        return 0;
+        return _C_start;
     }
-
-    if (_C_reset) { 
-        _C_reset = false;	  
+     
+    if (_C_reset) {
+        _C_reset = false;
         return _C_start;
     }
+
+    _RWSTD_ASSERT (0 < __n);
 
     ++_C_r_length [__n - 1];
 



Mime
View raw message