Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 13651 invoked from network); 6 Jun 2008 18:40:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Jun 2008 18:40:59 -0000 Received: (qmail 87927 invoked by uid 500); 6 Jun 2008 18:41:02 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 87913 invoked by uid 500); 6 Jun 2008 18:41:01 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 87902 invoked by uid 99); 6 Jun 2008 18:41:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jun 2008 11:41:01 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.roguewave.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jun 2008 18:40:06 +0000 Received: from exchmail01.Blue.Roguewave.Com (exchmail01.blue.roguewave.com [10.22.129.22]) by moroha.roguewave.com (8.13.6/8.13.6) with ESMTP id m56IeRm0006521 for ; Fri, 6 Jun 2008 18:40:27 GMT X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: svn commit: r663377 - in /stdcxx/branches/4.2.x: include/valarray src/valarray.cpp tests/numerics/26.class.gslice.cpp tests/regress/26.valarray.sub.stdcxx-955.cpp Date: Fri, 6 Jun 2008 12:40:23 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: svn commit: r663377 - in /stdcxx/branches/4.2.x: include/valarray src/valarray.cpp tests/numerics/26.class.gslice.cpp tests/regress/26.valarray.sub.stdcxx-955.cpp Thread-Index: AcjH6yxyYq28ay2KRdOi4MEcSZMWugADdcDw References: <20080604214836.C2E492388A06@eris.apache.org> <48495931.4070409@roguewave.com> From: "Travis Vitek" To: X-Virus-Checked: Checked by ClamAV on apache.org =20 Martin Sebor wrote: > >vitek@apache.org wrote: >> Author: vitek >> Date: Wed Jun 4 14:48:36 2008 >> New Revision: 663377 >>=20 >[...] >> Modified: stdcxx/branches/4.2.x/src/valarray.cpp >> URL:=20 >http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/valarray >.cpp?rev=3D663377&r1=3D663376&r2=3D663377&view=3Ddiff >>=20 >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- stdcxx/branches/4.2.x/src/valarray.cpp (original) >> +++ stdcxx/branches/4.2.x/src/valarray.cpp Wed Jun 4 14:48:36 2008 >> @@ -41,8 +41,12 @@ >> { >> _RWSTD_SIZE_T __n =3D _C_length.size (); >> =20 >> - while (__n && _C_r_length [__n - 1] =3D=3D _C_length [__n - 1] - = 1) >> - --__n; >> + for (/**/; __n; --__n) >> + { > >The brace should be on the line above :) > Blarg! >> + if ( _C_length [__n - 1] >> + && _C_r_length [__n - 1] !=3D _C_length [__n - 1] - 1) > >Also, I wonder if it might help generate more optimal code to write >the loop like so: > > while (__n) { > --__n; > > if (_C_length [n] && _C_r_length [n] !=3D _C_length [n] - 1) > break; > } > It is possible it would help generate better code, but this code changes the behavior of the loop. We now decrement __n before checking the condition; when we break __n will be off-by-one. Obviously we can deal with that by incrementing __n before the break. I'll take a quick look at some disassembly and decide if it is worth making the change or not. >The duplicate check for (0 =3D=3D n) below could probably be hoisted >into the loop for even more optimal code, something like this: > > for ( ; ; ) { > if (0 =3D=3D n) { > _C_reset =3D true; > break; > } > > --n; > > if (_C_length [n] && _C_r_length [n] !=3D _C_length [n] - 1) > break; > } > >> + break; >> + } >> =20 >> if (0 =3D=3D __n) { >> _C_reset =3D true; >>=20