Hi Philippe, > > Do you know of a better solution (than returning to the loop)? There is a solution. Simple example for int, for others is similar: root.exe [0] int a[10] root.exe [1] a[0]=2004 (const int)2004 root.exe [2] memcpy(a+1,a,9*4) (void*)0x87f9c84 root.exe [3] a[1] (int)2004 root.exe [4] a[2] (int)2004 Victor Victor M. Perevoztchikov perev@bnl.gov Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000 tel office : 631-344-7894; fax 631-344-4206; ----- Original Message ----- From: "Peter Elmer" <Peter.Elmer@cern.ch> To: "Philippe Canal" <pcanal@fnal.gov> Cc: <roottalk@pcroot.cern.ch> Sent: Friday, April 02, 2004 1:52 PM Subject: Re: [ROOT] TArrayI::Reset() implementation change > > Hi Philippe, > > On Fri, Apr 02, 2004 at 12:30:38PM -0600, Philippe Canal wrote: > > I don't think that this is intentional. > > The change was made (incorrectly!) to improve speed without changing > > behavior. > > > > Do you know of a better solution (than returning to the loop)? > > Sorry, unfortunately no. (In fact it was even pointed out to me by > someone in BaBar that "memset isn't even consistently faster than a simple > loop", at least according to some tests done a few years ago. I've not > verified that myself.) > > Pete > > > > -----Original Message----- > > From: owner-roottalk@pcroot.cern.ch > > [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Peter Elmer > > Sent: Friday, April 02, 2004 6:07 AM > > To: roottalk@pcroot.cern.ch > > Subject: [ROOT] TArrayI::Reset() implementation change > > > > > > Hi Rene, > > > > I see that between ROOT 3.10-01 and 3.10-02, the following change was made > > to TArrayI::Reset(...): > > > > < // @(#)root/cont:$Name: $:$Id: TArrayI.h,v 1.14 2002/10/30 20:39:50 brun > > Exp $ > > --- > > > // @(#)root/cont:$Name: $:$Id: TArrayI.h,v 1.16 2003/11/14 11:17:13 brun > > Exp $ > > 44c44 > > < void Copy(TArrayI &array) const {array.Set(fN); for (Int_t > > i=0;i<fN;i++) array.fArray[i] = fArray[i];} > > --- > > > void Copy(TArrayI &array) const {array.Set(fN,fArray);} > > 48,49c48 > > < void Reset() {memset(fArray, 0, fN*sizeof(Int_t));} > > < void Reset(Int_t val) {for (Int_t i=0;i<fN;i++) fArray[i] = > > val;} > > --- > > > void Reset(Int_t val=0) {memset(fArray,val, > > fN*sizeof(Int_t));} > > > > For values of val other than 0, I think this actually changes the > > implementation since memset (IIRC) fills the array >byte-by-byte< with > > the value "val" (and not array-index by array-index). Was that change > > intentional? (We were relying on the original implementation in some of our > > code.) > > > > thanks, > > Pete > > > > > > ------------------------------------------------------------------------- > Peter Elmer E-mail: Peter.Elmer@cern.ch Phone: +41 (22) 767-4644 > Address: CERN Division PPE, Bat. 32 2C-14, CH-1211 Geneva 23, Switzerland > ------------------------------------------------------------------------- >
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET