Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c Subject: Re: p[1] vs. *(p+1) Message-ID: <29605:Aug3120:51:0290@kramden.acf.nyu.edu> Date: 31 Aug 90 20:51:02 GMT References: <26D952F5.4E44@tct.uucp> <1745@io.UUCP> <1990Aug31.190103.15043@laguna.ccsf.caltech.edu> Organization: IR Lines: 17 In article <1990Aug31.190103.15043@laguna.ccsf.caltech.edu> bruce@seismo.gps.caltech.edu (Bruce Worden) writes: > In article <1745@io.UUCP> prs@eng.ileaf.com (Paul Schmidt) writes: > >I must confess that I use p[1] in these cases, and count on the compiler > >to optimize for me. > In a simple case like p[1] the compiler may well optimize, but then it isn't > a particularly time consuming operation. Huh? p[1] means exactly the same thing as *(p+1). At least two compilers here (neither pcc-based) do that translation as the very first step. There's no ``optimization'' involved. > *p1++ = *a1++ * *b1++; > p2[i] = a2[i] * b2[i]; Note that on vector machines the latter is much faster in a loop. ---Dan